Re: [selectors-api] Why have two identical differently named interfaces?

On Mar 13, 2008, at 4:53 AM, Alex Russell wrote:

>
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> On Mar 12, 2008, at 8:46 AM, liorean wrote:
>
>>
>> On 12/03/2008, Boris Zbarsky <bzbarsky@mit.edu> wrote:
>>> I guess I could do the two interfaces, but I'm having a hard time  
>>> seeing
>>> different extensions being made to these two interfaces (as
>> opposed to wholly
>>> new interfaces being invented, as was done here).
>>
>> I can actually imagine one extension that only makes sence on  
>> elements
>> and not on any other nodes - element-rooted instead of
>> subtree-only-but-document-rooted queries. (I don't see any real
>> benefit from such an interface though, but I've seen the idea
>> mentioned on the mailing lists.)
>
> The benefit here is the (potential) ability to root queries to  
> containing nodes. Nearly every JavaScript library that does CSS  
> selectors handles the equivalent of:
>
> 	node.querySelectorAll("> .thinger");
>
> Which currently has no expression via valid CSS 3 selectors. There's  
> no concept of a query being a descendant of a selector root node  
> although the above use-case occurs very frequently in real-world  
> scripts.
>
> It seems foolish to extend the CSS 3 selectors WD to support a  
> syntax that is simple-selector free, whereas it has use in the DOM- 
> centric APIs.
>
> Whether this needs to be handled via separate interfaces, I can't  
> say (and don't care).

Maybe the best solution would be to add a :scope pseudo-element which  
is the target of the querySelectorAll call if not called on the  
document. That would allow old-school JS library semantics just by  
prepending ":scope ".

Regards,
Maciej

Received on Friday, 14 March 2008 00:19:07 UTC