Re: QSA, the problem with ":scope", and naming

On 10/20/11 4:32 PM, Tab Atkins Jr. wrote:
> I don't really see the performance issues.  If you use + or ~ off of
> :scope, you know for a fact that all the nodes come *after* any
> selectors that don't have :scope.

Yes.

> 1. Run the :scope-carrying selectors across the document together,
> automatically yielding a dom-ordered list.
> 2. Run the :scope-absent selectors together, automatically yielding a
> dom-ordered list.
> 3. Find where the scoping element would be inserted in the #1 list,
> and insert the entire #2 list there.

   foo.find(":scope + div, :scope div")

begs to differ.

So does:

   foo.find("span :scope ~ div, span > :scope div)

(which is not quite as trivial to analyze).

You could try to look at the combinator following the part(s) that have 
:scope, but that can get tricky.

And worse yet, the current :scope proposals allow an arbitrary nodeset 
to be specified as matching :scope, at which point this whole thing is 
out the window.

And yes, if you use a subject indicator then performance goes out the 
window too; you basically have to search the whole DOM.

As long as you're ok with searching the whole DOM any time anything 
funny is happening, of course, there's no other performance issue here. 
  But then I suspect this will be slow to start with....

-Boris

Received on Thursday, 20 October 2011 21:05:10 UTC