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

Define Event.srcElement and Event.returnValue #626

Merged
merged 1 commit into from
Apr 9, 2018

Conversation

miketaylr
Copy link
Member

@miketaylr miketaylr commented Mar 30, 2018

@cvrebert
Copy link
Member

cvrebert commented Apr 2, 2018

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

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

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.

Copy link
Member

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.

@miketaylr miketaylr changed the title Issue #625. Define Event.srcElement and Event.returnValue for compat. Fixes #625. Define Event.srcElement and Event.returnValue for compat. Apr 5, 2018
@miketaylr
Copy link
Member Author

Fixes #625. (References in titles don't create cross-references in GitHub.)

(once the commit lands it should, but thanks!)

@miketaylr
Copy link
Member Author

r? @cvrebert @annevk

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

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

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

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

Copy link
Member

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}} ..."

Copy link
Member

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

Choose a reason for hiding this comment

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

[...] and do nothing otherwise.

@miketaylr
Copy link
Member Author

Changes made, thanks @annevk @cvrebert.

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.
@annevk annevk changed the title Fixes #625. Define Event.srcElement and Event.returnValue for compat. Define Event.srcElement and Event.returnValue Apr 9, 2018
@annevk
Copy link
Member

annevk commented Apr 9, 2018

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

@cvrebert
Copy link
Member

cvrebert commented Apr 9, 2018

The other relevant Chrome bug is https://bugs.chromium.org/p/chromium/issues/detail?id=692695
Looks like we need a WebKit bug for changing its returnValue to be no more powerful than preventDefault() ?
I couldn't find a Mozilla bug for implementing returnValue.

@annevk
Copy link
Member

annevk commented Apr 9, 2018

Yeah, Edge and WebKit.

@annevk
Copy link
Member

annevk commented Apr 9, 2018

(Travis is complaining due to validator/validator#634 btw.)

@annevk
Copy link
Member

annevk commented Apr 9, 2018

Firefox bug for returnValue: https://bugzilla.mozilla.org/show_bug.cgi?id=1452569.

@annevk annevk merged commit e36b369 into whatwg:master Apr 9, 2018
hubot pushed a commit to WebKit/WebKit-http that referenced this pull request Apr 16, 2018
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
Zirro added a commit to Zirro/jsdom that referenced this pull request Apr 16, 2018
Zirro added a commit to Zirro/jsdom that referenced this pull request Apr 23, 2018
Zirro added a commit to Zirro/jsdom that referenced this pull request Apr 25, 2018
domenic pushed a commit to jsdom/jsdom that referenced this pull request Apr 26, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants