W3C home > Mailing lists > Public > www-style@w3.org > September 2014

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

From: Boris Zbarsky <bzbarsky@mit.edu>
Date: Tue, 02 Sep 2014 12:53:13 -0400
Message-ID: <5405F5F9.9020801@mit.edu>
To: "Tab Atkins Jr." <jackalmage@gmail.com>
CC: Anne van Kesteren <annevk@annevk.nl>, "www-style@w3.org" <www-style@w3.org>, "www-dom@w3.org" <www-dom@w3.org>, David Håsäther <hasather@gmail.com>
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().


> #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.

Received on Tuesday, 2 September 2014 16:53:49 UTC

This archive was generated by hypermail 2.4.0 : Friday, 25 March 2022 10:08:46 UTC