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

Re: [selectors4] Upwards Ancestor Traversal API

From: David Håsäther <hasather@gmail.com>
Date: Mon, 6 Jan 2014 19:35:55 +0100
Message-ID: <CAMPaTMe7vOPM8xjLggeouKe1izCrP6D=DWEue3Jmws4a71vW0g@mail.gmail.com>
To: Garrett Smith <dhtmlkitchen@gmail.com>
Cc: www-style@w3.org
On Mon, Jan 6, 2014 at 7:13 PM, Garrett Smith <dhtmlkitchen@gmail.com> wrote:
> For event bubbling, it is very useful to traverse up the DOM tree to
> find an ancestor. For example:
>
>  findAncestorWithClass(el, className,  /*opt*/ container);
>  findAncestorWithAttribute(el, attName, /*opt*/ value);
>  jqueryObj.closest(selectorText, /*opt*/ context)
>
> It would be useful to have an API that traverses up the DOM tree and
> tests each Element against a selector and returns either an Element or
> null.

Agreed, very useful. There is an issue filed for the DOM spec:
https://www.w3.org/Bugs/Public/show_bug.cgi?id=16488

-- 
David Håsäther
Received on Monday, 6 January 2014 18:36:43 UTC

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