Re: Behavior of matches() and closest() with :scope()
"Tab Atkins Jr." <[email protected]>
| Newsgroups | gmane.comp.web.dom.general,gmane.comp.web.css.general |
|---|---|
| Message-ID | <CAAWBYDA2_SYc8T7pLePeRsjf6V0woDe9vDDDm+jSv33Nc3Yhsw@mail.gmail.com> |
On Thu, Sep 4, 2014 at 2:54 AM, Anne van Kesteren <[email protected]> wrote: > On Tue, Sep 2, 2014 at 6:53 PM, Boris Zbarsky <[email protected]> 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). I suppose I can't come up with any decent use-cases for closest() with a :scope matching the current ancestor. Let's go with #1, since it does have a decent use-case associated with it. ~TJ