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 26863 - invoking filter
Summary: invoking filter
Status: RESOLVED FIXED
Alias: None
Product: WebAppsWG
Classification: Unclassified
Component: DOM (show other bugs)
Version: unspecified
Hardware: PC Linux
: P2 normal
Target Milestone: ---
Assignee: Anne
QA Contact: public-webapps-bugzilla
URL: https://dom.spec.whatwg.org/#concept-...
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-09-19 18:39 UTC by Philippe Le Hegaret
Modified: 2014-09-20 10:41 UTC (History)
3 users (show)

See Also:


Attachments

Description Philippe Le Hegaret 2014-09-19 18:39:58 UTC
What does "invoking filter" mean when presented with the following one:

var filter = function() { return FILTER_ACCEPT; };
    filter.acceptNode = function(node) { return FILTER_SKIP; };
Comment 1 Boris Zbarsky 2014-09-19 18:47:43 UTC
There should be no "invoking filter".  There should just be calling of the acceptNode method on filter....
Comment 2 Philippe Le Hegaret 2014-09-19 20:21:10 UTC
Implementations will either take a Function or an Object with the acceptNode function for the filter parameter, so it's not just about calling the acceptNode method. The spec has a note for that effect already. However, when both are offered, implementations will use the function directly (ie the filter will return FILTER_ACCEPT in this case) and acceptNode will not get called. The spec is however silent on which one to choose.
Comment 3 Boris Zbarsky 2014-09-20 01:13:17 UTC
No, implementations take an instance of the NodeFilter callback interface, which always has an acceptNode method.

This is a single-operation callback interface, which means you can pass in a function as an implementation of it in the ECMAScript binding.

Then when acceptNode is called you end up at http://heycam.github.io/webidl/#es-user-objects step 1 substep 3, discover that IsCallable(O) is true, and set X to O.  Then in step 1 substep 11 subsubstep 1 the [[Call]] of X is invoked, which calls the function in question.

So in particular, in the case of comment 0 the filter will return FILTER_ACCEPT, and this is perfectly well specified by Web IDL as long as the DOM spec says to call the acceptNode method on the callback interface object.
Comment 4 Anne 2014-09-20 08:18:28 UTC
In the same way as https://dom.spec.whatwg.org/#concept-event-listener-invoke I guess.

(I wish bug 25138 and especially bug 17713 were fixed already.)