W3C home > Mailing lists > Public > public-webapi@w3.org > February 2008

Re: [selectors-api]

From: Boris Zbarsky <bzbarsky@MIT.EDU>
Date: Fri, 15 Feb 2008 17:51:04 -0600
Message-ID: <47B62568.2000005@mit.edu>
To: Anne van Kesteren <annevk@opera.com>
CC: public-webapi@w3.org

Anne van Kesteren wrote:
>>> To ensure that naïve implementors don't overlook the potential issue 
>>> here. An implementation of NSResolver can be provided by the script 
>>> author as the specification explains and the script author can do all 
>>> kinds of weird things that don't match a conforming implementation of 
>>> NSResolver (such as mutating the DOM tree).
>>
>> Is a conforming querySelector implementation allowed to throw an 
>> exception when this happens?
> 
> No. It is only allowed to throw an exception when the text says so.

In that case, can you please describe what is a conforming behavior for a 
querySelector (or querySelectorAll) implementation if:

1)  It needs to call the NSResolver on every match attempt
2)  The NSResolver mutates the DOM on every match attempt

Throwing an exception is not conformant.  Is returning null from querySelector 
conformant?  Is returning a node that is not first in the document?  Is 
returning an empty list from querySelectorAll?  Returning a list that's not in 
document order?  Returning a list in which a node is present twice?

If we read the spec literally, as you do here, the answers to all those are "no".

If you're going to require the implementation to "deal" with NSResolvers which 
do random stuff but put too many constraints on what it's allowed to do to deal 
with them (as you are), you make an implementation impossible.

Now maybe you're actually requiring that the number of calls to the NSResolver 
for any given selector and initial DOM tree is bounded in the face of all 
possible mutations by the NSResolver and that hence the DOM will at some point 
stabilize and it will be possible to return the things the spec requires be 
returned.  But if that's a constraint you want to place on implementations, you 
should probably spell it out clearly.

Note that in Gecko I suspect the NSResolver would only be called during the 
parsing of the selector, so we could in fact return the things the spec 
requires... on the post-mutation DOM, not the pre-mutation one.  It's not clear 
to me from the spec whether this would be conformant.

-Boris
Received on Friday, 15 February 2008 23:50:59 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Friday, 15 February 2008 23:50:59 GMT