-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rewrite event handlers #3850
Rewrite event handlers #3850
Conversation
06c31f6
to
65a805f
Compare
This is now ready to be reviewed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks really great. I hope to have time next week for a more detailed review. What would help with that is a small write-up (that we can eventually use in the commit message) of what is being changed and why. As this seemingly changes a bit more than just the lack of removal of event listeners added through event handlers.
element, replace the generic <span>event handlers</span> with the same names normally supported by | ||
<span>HTML elements</span>.</p> | ||
<p>The <span>event handlers</span> of the <code>Window</code> object named by the | ||
<span><code>Window</code>-reflecting body element event handler set</span>, exposed on the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
body should be in <code>
here, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It applies to frameset
elements too, and I was trying to allude to the body element.
source
Outdated
element, then return <var>eventTarget</var>.</p></li> | ||
|
||
<li><p>If <var>name</var> is not the name of an attribute of the <code>WindowEventHandlers</code> | ||
interface mixin, and if <span><code>Window</code>-reflecting body element event handler |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/, and if/ and the/
(you could keep the additional comma I suppose, but I usually try to omit it if there's only two items)
source
Outdated
<var>eventTarget</var>.</p></li> | ||
|
||
<li><p>If <var>eventTarget</var>'s <span>node document</span> is not an <span>active | ||
document</span>, then return null.</p></li> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a little surprising this step comes this late. This is only applicable to body and frameset elements?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes that's correct. The key here is that we want to make sure the event handler name check is before "active document" check.
This is tested in https://github.com/web-platform-tests/wpt/blob/7cdedf945221ce000c977008769a09b034e87716/html/webappapis/scripting/events/event-handler-attributes-windowless-body.html.
Of course.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pushed some minor tweaks, but LGTM. Would love @annevk's review too.
I made a half-hearted attempt at sectioning out this mega-section into subsections, but it didn't work. I'll file a follow-up issue explaining and brainstorming for the future.
Oh, shoot, I forgot. I don't think this works after all:
In particular this will not bail out for I think this might be correct:
|
@domenic Unfortunately, what you described doesn't seem to be what browsers implement: const b = document.createElement("body");
const f = () => {};
b.onblur = f;
console.assert(b.onblur === f);
console.assert(window.onblur === f); On Chrome, Safari, and Firefox this code executes fine. I guess I should add another test case then. |
That seems quite broken, but if everyone agrees, then it's probably not worth fixing. Amazing... Edit: we may even want to add a spec note/example about this unusual fact. |
…a=testonly Automatic update from web-platform-testsHTML event handlers: More uniform naming convention -- HTML event handlers: Use .window.js instead of .html for some files -- HTML event handlers: Use IDL parser for list of event handlers -- HTML event handlers: Use synchronous test() where able -- HTML event handlers: Additionally test unshadowed event handlers -- HTML: tests for new event handler spec See: whatwg/html#3850 -- HTML event handlers: Test document.createElement("body") -- wpt-commits: db24506f8af9048c0a80d89c9981ef445d6c3af9, 3e273bc58ae2af40f4b00b514f2fd6d604ffc98d, 8bf45a39c3435737ebc862904af245d27b68efce, 776041862ca0cab7a8dd10e29361dbf3359a0b2f, fa58a12fc565fc152bff196e803fd9290dfa1bc7, fc2eba9d6f0a860c0db1457852124e320fd8d499, 8e668a6b63e5dbb68304c182fdc1f7b4e6edaf96 wpt-pr: 12201
…a=testonly Automatic update from web-platform-testsHTML event handlers: More uniform naming convention -- HTML event handlers: Use .window.js instead of .html for some files -- HTML event handlers: Use IDL parser for list of event handlers -- HTML event handlers: Use synchronous test() where able -- HTML event handlers: Additionally test unshadowed event handlers -- HTML: tests for new event handler spec See: whatwg/html#3850 -- HTML event handlers: Test document.createElement("body") -- wpt-commits: db24506f8af9048c0a80d89c9981ef445d6c3af9, 3e273bc58ae2af40f4b00b514f2fd6d604ffc98d, 8bf45a39c3435737ebc862904af245d27b68efce, 776041862ca0cab7a8dd10e29361dbf3359a0b2f, fa58a12fc565fc152bff196e803fd9290dfa1bc7, fc2eba9d6f0a860c0db1457852124e320fd8d499, 8e668a6b63e5dbb68304c182fdc1f7b4e6edaf96 wpt-pr: 12201
This change aligns the event listener removal behavior with implementations, specifically in two aspects: - The event handler's value should be set to null (i.e., deactivated). - Event listeners and handlers should be removed from the Window object as well. See prior investigation around deactivation of event handlers in whatwg#3836 and whatwg#3850. See investigation around `document.open()`'s behavior in whatwg#3818. Tests: web-platform-tests/wpt#12122
This change aligns the event listener removal behavior with implementations, specifically in two aspects: - The event handler's value should be set to null (i.e., deactivated). - Event listeners and handlers should be removed from the Window object as well. See prior investigation around deactivation of event handlers in #3836 and #3850. See investigation around document.open()'s behavior in #3818. Tests: web-platform-tests/wpt#12122
This change aligns the event listener removal behavior with implementations, specifically in two aspects: - The event handler's value should be set to null (i.e., deactivated). - Event listeners and handlers should be removed from the Window object as well. See prior investigation around deactivation of event handlers in whatwg#3836 and whatwg#3850. See investigation around document.open()'s behavior in whatwg#3818. Tests: web-platform-tests/wpt#12122
This change aligns the event listener removal behavior with implementations, specifically in two aspects: - The event handler's value should be set to null (i.e., deactivated). - Event listeners and handlers should be removed from the Window object as well. See prior investigation around deactivation of event handlers in whatwg#3836 and whatwg#3850. See investigation around document.open()'s behavior in whatwg#3818. Tests: web-platform-tests/wpt#12122
…a=testonly Automatic update from web-platform-testsHTML event handlers: More uniform naming convention -- HTML event handlers: Use .window.js instead of .html for some files -- HTML event handlers: Use IDL parser for list of event handlers -- HTML event handlers: Use synchronous test() where able -- HTML event handlers: Additionally test unshadowed event handlers -- HTML: tests for new event handler spec See: whatwg/html#3850 -- HTML event handlers: Test document.createElement("body") -- wpt-commits: db24506f8af9048c0a80d89c9981ef445d6c3af9, 3e273bc58ae2af40f4b00b514f2fd6d604ffc98d, 8bf45a39c3435737ebc862904af245d27b68efce, 776041862ca0cab7a8dd10e29361dbf3359a0b2f, fa58a12fc565fc152bff196e803fd9290dfa1bc7, fc2eba9d6f0a860c0db1457852124e320fd8d499, 8e668a6b63e5dbb68304c182fdc1f7b4e6edaf96 wpt-pr: 12201 UltraBlame original commit: 240261e9447c0e8ec0e0b25ec09ca905c70c317d
…a=testonly Automatic update from web-platform-testsHTML event handlers: More uniform naming convention -- HTML event handlers: Use .window.js instead of .html for some files -- HTML event handlers: Use IDL parser for list of event handlers -- HTML event handlers: Use synchronous test() where able -- HTML event handlers: Additionally test unshadowed event handlers -- HTML: tests for new event handler spec See: whatwg/html#3850 -- HTML event handlers: Test document.createElement("body") -- wpt-commits: db24506f8af9048c0a80d89c9981ef445d6c3af9, 3e273bc58ae2af40f4b00b514f2fd6d604ffc98d, 8bf45a39c3435737ebc862904af245d27b68efce, 776041862ca0cab7a8dd10e29361dbf3359a0b2f, fa58a12fc565fc152bff196e803fd9290dfa1bc7, fc2eba9d6f0a860c0db1457852124e320fd8d499, 8e668a6b63e5dbb68304c182fdc1f7b4e6edaf96 wpt-pr: 12201 UltraBlame original commit: 240261e9447c0e8ec0e0b25ec09ca905c70c317d
…a=testonly Automatic update from web-platform-testsHTML event handlers: More uniform naming convention -- HTML event handlers: Use .window.js instead of .html for some files -- HTML event handlers: Use IDL parser for list of event handlers -- HTML event handlers: Use synchronous test() where able -- HTML event handlers: Additionally test unshadowed event handlers -- HTML: tests for new event handler spec See: whatwg/html#3850 -- HTML event handlers: Test document.createElement("body") -- wpt-commits: db24506f8af9048c0a80d89c9981ef445d6c3af9, 3e273bc58ae2af40f4b00b514f2fd6d604ffc98d, 8bf45a39c3435737ebc862904af245d27b68efce, 776041862ca0cab7a8dd10e29361dbf3359a0b2f, fa58a12fc565fc152bff196e803fd9290dfa1bc7, fc2eba9d6f0a860c0db1457852124e320fd8d499, 8e668a6b63e5dbb68304c182fdc1f7b4e6edaf96 wpt-pr: 12201 UltraBlame original commit: 240261e9447c0e8ec0e0b25ec09ca905c70c317d
Tests: web-platform-tests/wpt#12201
Fixes: #3836
/infrastructure.html ( diff )
/obsolete.html ( diff )
/sections.html ( diff )
/webappapis.html ( diff )