Re: Selectors: hooks needed by DOM

Le 01/10/2013 00:42, Tab Atkins Jr. a écrit :
> On Thu, Sep 12, 2013 at 7:40 AM, Anne van Kesteren <annevk@annevk.nl> wrote:
>> http://dom.spec.whatwg.org/ now defines the "Selectors API", i.e. the
>> query/queryAll/querySelector/querySelectorAll methods and a new
>> Elements object that has query/queryAll.
>>
>> I found the need for these hooks:
>>
>> 1) Parsing a selectors string and that either returning an opaque
>> representation of selectors or failure.
>>
>> 2) Parsing a relative selectors string against an
>> Element/Document/DocumentFragment node or set of Element nodes and
>> that either returning an opaque representation of selectors or
>> failure.
>>
>> 3) Matching an opaque representation of selectors against a tree using
>> a scoping root Element/Document/DocumentFragment node.
>>
>> I implement additional logic on top of 3) in
>> http://dom.spec.whatwg.org/#evaluate-a-relative-selectors-string and
>> this leads me to thinking that if you want to define that logic we
>> could instead define matching as an opaque representation of selectors
>> against an Element/Document/DocumentFragment node or set of Element
>> nodes. Because if you have the selectors and the node or set of nodes,
>> you can find the tree(s) and do all the work. Let me know how you'd
>> prefer to organize this.
>
> All right, I think I've defined everything you need:
> <http://dev.w3.org/csswg/selectors/#api-hooks>
>
> Let me know if something is missing or clumsy, and I'll try to adjust.

The parsing hooks should also return a failure for inputs that match the 
grammar and are recognized, but are invalid for another reason.

The "Invalid Selectors and Error Handling" section lists undeclared 
namespace prefixes as such a reason, but it’s missing improper nesting 
of :not() and :matches() (although maybe that goes into "not recognized".)

-- 
Simon Sapin

Received on Tuesday, 1 October 2013 07:59:23 UTC