Skip to content

[cssom-view] The addListener(listener) spec doesn't match with current DOM spec #4407

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

Closed
zcorpan opened this issue Oct 10, 2019 · 1 comment · Fixed by #4408
Closed

[cssom-view] The addListener(listener) spec doesn't match with current DOM spec #4407

zcorpan opened this issue Oct 10, 2019 · 1 comment · Fixed by #4408

Comments

@zcorpan
Copy link
Member

zcorpan commented Oct 10, 2019

https://drafts.csswg.org/cssom-view/#example-5ecb609e

The addListener(listener) method must run these steps:​

If listener is null, terminate these steps.

Append an event listener to the associated list of event listeners with type set to change, callback set to listener, and capture set to false, unless there already is an event listener in that list with the same type, callback, and capture.

The removeListener(listener) method must run these steps:​

Remove an event listener from the associated list of event listeners, whose type is change, callback is listener, and capture is false.

This doesn't hook into DOM correctly anymore, I believe. It probably did when it was written but the DOM spec has since changed.

See https://dom.spec.whatwg.org/#dom-eventtarget-addeventlistener

cssom-view should say something like

The addListener(callback) method, when invoked, must run these steps:

  1. [Add an event listener] with the [context object] and an [event listener] whose type is change, callback is callback, capture is false, passive is false, and once is false.

The removeListener(callback) method, when invoked, must run these steps:

  1. If the [context object]’s [event listener list] [contains] an [event listener] whose type is change, callback is callback, and capture is false, then [remove an event listener] with the [context object] and that [event listener].

Related tests: web-platform-tests/wpt#18390 cc @shvaikalesh @annevk

@annevk
Copy link
Member

annevk commented Oct 10, 2019

You don't have to set capture/passive/once. Only if you want them to have a non-default value.

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

Successfully merging a pull request may close this issue.

2 participants