Re: Behavior of matches() and closest() with :scope()

Boris Zbarsky <[email protected]>
Newsgroups gmane.comp.web.dom.general,gmane.comp.web.css.general
Message-ID <[email protected]>
On 9/2/14, 12:42 PM, Tab Atkins Jr. wrote:
> For the same reason that :scope matches the element in .matches().

Ok, but why does it do that?  Are there situations in which this is 
actually useful for something?

> Anything you might want to pass to .matches(), you might want to pass
> to .closest().

Sure.

> #1 would allow you to write a .closest() selector which, paired with
> :has(), can explicitly reference the starting element,

Right.  Are there equally compelling use cases for the other option?

> but you can
> reproduce that if necessary by adding a uniquifier to the starting
> element and matching on that.

That's a super-gross (and super-slow!) hack.  I'd rather not force 
people into it unless required.

-Boris
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.