Skip to content
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

Merged
merged 10 commits into from
Aug 7, 2018
Merged

Rewrite event handlers #3850

merged 10 commits into from
Aug 7, 2018

Conversation

TimothyGu
Copy link
Member

@TimothyGu TimothyGu commented Jul 24, 2018

@TimothyGu TimothyGu force-pushed the event-handler branch 2 times, most recently from 06c31f6 to 65a805f Compare July 24, 2018 21:58
@TimothyGu TimothyGu changed the title [WIP] Rewrite event handlers Rewrite event handlers Jul 26, 2018
@TimothyGu
Copy link
Member Author

This is now ready to be reviewed.

@annevk annevk added needs tests Moving the issue forward requires someone to write tests topic: events labels Jul 26, 2018
Copy link
Member

@annevk annevk left a 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
Copy link
Member

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?

Copy link
Member Author

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
Copy link
Member

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>
Copy link
Member

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?

Copy link
Member Author

@TimothyGu TimothyGu Jul 26, 2018

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.

@TimothyGu TimothyGu removed the needs tests Moving the issue forward requires someone to write tests label Jul 26, 2018
@TimothyGu
Copy link
Member Author

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.

Of course.

Copy link
Member

@domenic domenic left a 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.

@domenic
Copy link
Member

domenic commented Jul 30, 2018

Oh, shoot, I forgot. I don't think this works after all:

If eventTarget's node document is not an active document, then return null.

In particular this will not bail out for const eventTarget = document.createElement("body") inside an active document.

I think this might be correct:

If eventTarget is not the body element of its node document.

@TimothyGu
Copy link
Member Author

@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.

@domenic
Copy link
Member

domenic commented Jul 31, 2018

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.

TimothyGu added a commit to web-platform-tests/wpt that referenced this pull request Jul 31, 2018
TimothyGu added a commit to web-platform-tests/wpt that referenced this pull request Jul 31, 2018
moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this pull request Aug 3, 2018
…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
jankeromnes pushed a commit to jankeromnes/gecko that referenced this pull request Aug 3, 2018
…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
@domenic domenic merged commit 753e9fe into whatwg:master Aug 7, 2018
@TimothyGu TimothyGu deleted the event-handler branch August 7, 2018 22:51
TimothyGu added a commit to TimothyGu/html that referenced this pull request Aug 9, 2018
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
domenic pushed a commit that referenced this pull request Aug 9, 2018
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
mustaqahmed pushed a commit to mustaqahmed/html that referenced this pull request Feb 15, 2019
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
mustaqahmed pushed a commit to mustaqahmed/html that referenced this pull request Feb 15, 2019
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
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified-and-comments-removed that referenced this pull request Oct 3, 2019
…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
gecko-dev-updater pushed a commit to marco-c/gecko-dev-comments-removed that referenced this pull request Oct 3, 2019
…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
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified that referenced this pull request Oct 3, 2019
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

3 participants