Check that .rel is available too#13983
Conversation
There was a problem hiding this comment.
What's meant by "available"? In a browser, an anchor node may not have an assigned rel attribute, at which point node.rel would be an empty string, thus falsey and as proposed here skipping the expected logic to assign the 'noreferrer noopener' value. It seems to me the entire purpose for this code to exist in the first place is to be assigning that value when not otherwise assigned. But if that's the case, then why aren't unit tests failing?
|
@hypest I think this is a bug in jsdom-jscore. The error message we are seeing has an error message that’s coming from JavascriptCore and html.js:110 If you look at the getter in line 95 you can see that they are checking if normalize is available before calling it and referencing this old issue. Since that is not defined and |
Hmm, that makes sense @aduth , I didn't look at it like that before. Under that light yeah, this change so far is just wrong. Will revise or drop the PR altogether! Thanks for the review pass! |
Ahh, it does look like that @koke , I see. Indeed, it seems that the failing call had to be guarded by a check for (not) String but it's not. The jsdom-jscore library we're using hasn't been updated for the last a year so, it seems we'll need to fork it to accommodate us at the time being. I will close this PR and fork+patch the library instead. We can explore options (including some already made forks) after fixing this. |
|
It's still curious to me that the build was passing. My previous comment was in-part a not-so-subtle hint that we should improve coverage, but in fact there are tests which are meant to verify its behavior: ¯\_(ツ)_/¯ |
Description
node.relcan be missing on native mobile so, guard for it.How has this been tested?
Using this gutenberg-mobile PR: wordpress-mobile/gutenberg-mobile#630
Types of changes
Adds a guard for
node.relto be present before setting it.Checklist: