Re: Remaining Problems with Explicit :scope Switching in find/findAll

On Sun, Nov 27, 2011 at 12:39 PM, Lachlan Hunt <lachlan.hunt@lachy.id.au> wrote:
> On 2011-11-27 21:29, Jonas Sicking wrote:
>>
>> Here is what I sent to the list on Nov 10th. Though it didn't get archived
>> so maybe it didn't go through properly:
>> ...
>
> I'll review your algorithm and respond to that a bit later.
>
>>>  foo.find(">label /for/ input+:scope~span)
>>
>> Can this expression ever match anything if we prepend ":scope"? Would
>> simply removing step 5 above make the steps work for this case too?
>
> Yes.
>
> <p>
>  <input id="x">
>  <strong>
>    <label for="x">X</label>
>  </strong>
>  <span>...</span>
> </p>
>
> var foo = document.find("strong");
> foo.find(">label /for/ input+:scope~span);
>
> After prepending :scope, that will match the span element.

Ok, so maybe removing step 5 from my suggested steps would work then.
Alternatively keeping them and saying that if you have a :scope in
your selector then we won't prepend one, and thus the above selector
wouldn't be valid selector syntax and thus should throw.

Either way seems like an ok solution.

The concern I have about always prepending :scope if the selector
starts with ">", even if :scope appears in the selector, is that it
creates different rules for the ">" combinator vs. the " " combinator.

/ Jonas

Received on Monday, 28 November 2011 06:18:31 UTC