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

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

From: Anne van Kesteren <annevk@annevk.nl>
Date: Thu, 4 Sep 2014 11:54:43 +0200
Message-ID: <CADnb78iEUsTmAqQNrwM0OYyGbcK9WkJ8dFcT8h9A93Zg3-BCMA@mail.gmail.com>
To: Boris Zbarsky <bzbarsky@mit.edu>
Cc: "Tab Atkins Jr." <jackalmage@gmail.com>, "www-style@w3.org" <www-style@w3.org>, "www-dom@w3.org" <www-dom@w3.org>, David Håsäther <hasather@gmail.com>
On Tue, Sep 2, 2014 at 6:53 PM, Boris Zbarsky <bzbarsky@mit.edu> wrote:
> ...

So let's see. If we don't pass a :scope elements argument we get

  E.matches(":scope") -> false
  E.closest(":scope") -> null
  E.closest(":has(> :scope)" -> null

If we pass E as :scope elements we get

  E.matches(":scope") -> true
  E.closest(":scope") -> E
  E.closest(":has(> :scope)" -> E's parent

Now for closest() we could also pass the current ancestor A as :scope
elements, then we get

  E.closest(":scope") -> E
  E.closest(":has(> :scope)" -> null

It seems to me that passing the element on which the method is invoked
as :scope elements (i.e. E) makes the most sense. That argues for 1).


-- 
http://annevankesteren.nl/
Received on Thursday, 4 September 2014 09:55:11 UTC

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