-
Notifications
You must be signed in to change notification settings - Fork 287
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
Define Event.srcElement and Event.returnValue #626
Conversation
Fixes #625. (References in titles don't create cross-references in GitHub.) |
dom.bs
Outdated
@@ -446,6 +447,7 @@ interface Event { | |||
|
|||
readonly attribute boolean bubbles; | |||
readonly attribute boolean cancelable; | |||
attribute boolean returnValue; |
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.
Also historical? We have preventDefault()
and defaultPrevented
nowadays.
dom.bs
Outdated
@@ -675,6 +680,12 @@ The <dfn attribute for=Event><code>bubbles</code></dfn> and | |||
<dfn attribute for=Event><code>cancelable</code></dfn> attributes | |||
must return the values they were initialized to. | |||
|
|||
<p>The <dfn attribute for=Event><code>returnValue</code></dfn> attribute must be initialized to true | |||
when an <a>event</a> is created. When the attribute is set to false it must set the <a>canceled flag</a> |
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.
When the attribute is set to
Should be phrased as a setter instead?: "The returnValue
attribute’s setter must [...]"
See cancelBubble
for an example of the getter/setter boilerplate verbiage.
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.
Yeah, I think phrasing this as a getter and setter (one paragraph each) (and not saying anything about initial state) would be best. The initial state doesn't really exist, since it just reflects the canceled flag.
(once the commit lands it should, but thanks!) |
dom.bs
Outdated
@@ -675,6 +680,12 @@ The <dfn attribute for=Event><code>bubbles</code></dfn> and | |||
<dfn attribute for=Event><code>cancelable</code></dfn> attributes | |||
must return the values they were initialized to. | |||
|
|||
<p>The <dfn attribute for=Event><code>returnValue</code></dfn> attribute's getter must return false | |||
if the <a>canceled flag</a> is set, and true otherwise. |
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.
if the <a>canceled flag</a> is set
if <a>context object</a>'s <a>canceled flag</a> is set
dom.bs
Outdated
<p>The <dfn attribute for=Event><code>returnValue</code></dfn> attribute's getter must return false | ||
if the <a>canceled flag</a> is set, and true otherwise. | ||
|
||
<p>The {{Event/returnValue}} attribute's setter must, if the given value is false, set the <a>canceled flag</a> |
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.
set context object's canceled flag
dom.bs
Outdated
if the <a>canceled flag</a> is set, and true otherwise. | ||
|
||
<p>The {{Event/returnValue}} attribute's setter must, if the given value is false, set the <a>canceled flag</a> | ||
if the {{Event/cancelable}} attribute value is true and the <a>in passive listener flag</a> is unset. |
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.
context object's in passive listener flag
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.
Also "the context object's {{Event/cancelable}} ..."
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.
Although maybe it would be nicer to refactor this and make it share an algorithm with preventDefault(). I can do that before landing I suppose.
dom.bs
Outdated
if the <a>canceled flag</a> is set, and true otherwise. | ||
|
||
<p>The {{Event/returnValue}} attribute's setter must, if the given value is false, set the <a>canceled flag</a> | ||
if the {{Event/cancelable}} attribute value is true and the <a>in passive listener flag</a> is unset. |
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.
[...] and do nothing otherwise.
Unfortunately the web depends on these. They are intentionally defined in such a way to not offer capabilities beyond the non-historical API for events. Tests: web-platform-tests/wpt#10258. Fixes whatwg#625 and fixes whatwg#627.
I made a couple tweaks so this also fixes #627. Do we have all the browser bugs that we need here? I found https://bugs.chromium.org/p/chromium/issues/detail?id=277851 against Chrome, but it's not quite scoped to this (I left a comment). For Firefox there's https://bugzilla.mozilla.org/show_bug.cgi?id=453968 for |
The other relevant Chrome bug is https://bugs.chromium.org/p/chromium/issues/detail?id=692695 |
Yeah, Edge and WebKit. |
(Travis is complaining due to validator/validator#634 btw.) |
Firefox bug for |
https://bugs.webkit.org/show_bug.cgi?id=184415 Reviewed by Darin Adler. LayoutTests/imported/w3c: Import test coverage from web-platform-tests/wpt#10258. * web-platform-tests/dom/events/AddEventListenerOptions-passive-expected.txt: * web-platform-tests/dom/events/AddEventListenerOptions-passive.html: * web-platform-tests/dom/events/Event-constructors.html: * web-platform-tests/dom/events/Event-defaultPrevented-after-dispatch-expected.txt: * web-platform-tests/dom/events/Event-defaultPrevented-after-dispatch.html: * web-platform-tests/dom/events/Event-defaultPrevented-expected.txt: * web-platform-tests/dom/events/Event-defaultPrevented.html: * web-platform-tests/dom/events/Event-dispatch-click.html: * web-platform-tests/dom/events/Event-dispatch-detached-click.html: * web-platform-tests/dom/events/Event-dispatch-other-document.html: * web-platform-tests/dom/events/Event-initEvent.html: * web-platform-tests/dom/events/Event-returnValue-expected.txt: Added. * web-platform-tests/dom/events/Event-returnValue.html: Added. * web-platform-tests/dom/events/EventListener-handleEvent.html: * web-platform-tests/dom/events/EventTarget-dispatchEvent-returnvalue-expected.txt: * web-platform-tests/dom/events/EventTarget-dispatchEvent-returnvalue.html: * web-platform-tests/dom/events/w3c-import.log: * web-platform-tests/dom/interfaces-expected.txt: * web-platform-tests/interfaces/dom.idl: Source/WebCore: Update Event.returnValue setter to match the latest DOM specification after: - whatwg/dom#626 In particular, the returnValue setter is now a no-op if the new flag value is true. If the input flag value is false, it only sets the 'canceled' flag if the event is cancelable and the event’s in passive listener flag is unset. Test: imported/w3c/web-platform-tests/dom/events/Event-returnValue.html * dom/Event.cpp: (WebCore::Event::setLegacyReturnValue): (WebCore::Event::setCanceledFlagIfPossible): (WebCore::Event::preventDefault): * dom/Event.h: git-svn-id: http://svn.webkit.org/repository/webkit/trunk@230664 268f45cc-cd09-0410-ab3c-d52691b4dbfc
These were added to the spec in whatwg/dom#626.
These were added to the spec in whatwg/dom#626.
These were added to the spec in whatwg/dom#626.
These were added to the spec in whatwg/dom#626.
wpt: web-platform-tests/wpt#10258
r? @annevk
Preview | Diff