This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 27191 - "callback interface NodeFilter"
Summary: "callback interface NodeFilter"
Status: RESOLVED INVALID
Alias: None
Product: WebAppsWG
Classification: Unclassified
Component: DOM (show other bugs)
Version: unspecified
Hardware: All All
: P2 normal
Target Milestone: ---
Assignee: Anne
QA Contact: public-webapps-bugzilla
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-10-29 17:29 UTC by Domenic Denicola
Modified: 2014-10-29 17:44 UTC (History)
5 users (show)

See Also:


Attachments

Description Domenic Denicola 2014-10-29 17:29:35 UTC
https://dom.spec.whatwg.org/#interface-nodefilter

[[
callback interface NodeFilter
]]

I think this is wrong, or at least confusing. Looking at https://heycam.github.io/webidl/#dfn-callback-interface,

> Callback interfaces are ones that can be implemented by user objects and not by platform objects, as described in section 3.9 below. 

Also

> Static attributes and static operations MUST NOT be defined on a callback interface. 

Which doesn't specifically call out `const`s, but seems the same in spirit.

Additionally, while `window.NodeFilter` exists in all browsers, `window.EventListener` does not, and earlier the spec declares `callback interface EventListener` very similarly. I think (but am not sure) per WebIDL callback interfaces don't exist globally.

Suggested correction, if I am understanding this correctly:

- Add a separate `interface NodeFilter` that shows up on the global, has constants, and has an `acceptNode` method.
- Add `callback interface NodeFilterCallback` that contains only `acceptNode` and is used by createNodeIterator and createTreeWalker.
- Specify that passing a `NodeFilterCallback` (which could just be a plain function, per the definition of callback interfaces) to e.g. createNodeIterator causes the creation of a new `NodeFilter` object that is reflected by the `filter` property of the created node iterator.

Does this make sense? Am I on to something or just missing the idea entirely?
Comment 1 Boris Zbarsky 2014-10-29 17:36:48 UTC
> Which doesn't specifically call out `const`s, but seems the same in spirit.

It doesn't call them out because they're allowed on callback interfaces.

> I think (but am not sure) per WebIDL callback interfaces don't exist globally.

http://heycam.github.io/webidl/#es-interfaces is pretty clear on this: they exist if they have constants.
Comment 2 Domenic Denicola 2014-10-29 17:42:56 UTC
Ah OK. Thanks for catching me!

(It would be really nice if the ES mapping was not so separated from the definition -_-)
Comment 3 Boris Zbarsky 2014-10-29 17:44:34 UTC
Yeah, this split between "es bindings" and "language-independent stuff" is annoying.  :(