Skip to content

Conversation

@shawwn
Copy link
Contributor

@shawwn shawwn commented Jul 17, 2019

Without this PR, document.createElement('style').innerHTML incorrectly returns undefined:

> document.createElement('style').innerHTML
undefined

With this PR, .innerHTML is correctly returned:

> document.createElement('style').innerHTML
''

RangerMauve and others added 30 commits June 30, 2019 15:24
Remove sinon usage from HTMLAnchorElement test
Centralize window.location in WindowBase
Make Node insertBefore work with null reference node
Avaer Kazmer and others added 26 commits July 13, 2019 22:40
Add iterable support for DOM attributes
WebSocket origin header setting support
Add some HTMLIFrameElement stub methods
get innerHTML() {
return super.innerHTML;
}
set innerHTML(innerHTML) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be more correct to also construct and attach e.g. a Text node in the setter?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure, but the intent of this PR is to fix the bug introduced by defining set innerHTML without defining get innerHTML. Forwarding to super.innerHTML takes care of the issue.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this correctly return the set .innerHTML, or just default to the empty string?

If the superclass handles this, is it more appropriate to simply remove the interception on this subclass and let the parent class handle the innerHTML logic?

More generally, we should take the opportunity to "do the right thing" with regard to innerHTML setting on HTMLStyleElement. I'm confident many libraries in the wild depend on getting this correct.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is proof that you will go to any length not to merge pull requests from outside contributors (or at least from me). It speaks to the effectiveness of this project.

Even simple bug fixes are endlessly debated, analyzed, and random "what if?" scenarios are brought up for no apparent reason.

There is zero – and I do mean zero – reason not merge this PR. Your code for HTMLStyleElement is broken. This PR fixes it.

Merge it and make it better, if you want. Or do your usual thing of let it sit for 3 months and then do the same exact thing yourself in a slightly different way.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Yes, libraries do rely on HTMLStyleElement .innerHTML actually returning the innerHTML. This is exactly the problem I ran into with exokit DOM, and why I spent time submitting this PR. It actually breaks for actual websites right now.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants