- From: Garrett Smith <dhtmlkitchen@gmail.com>
- Date: Mon, 6 Jan 2014 10:13:17 -0800
- To: www-style@w3.org
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. Proposal: querySelectorAncestor(startNode, selectorText[, optional Node container); If container is not specified, container is the root node. Let currentParent be startNode.parentNode. While currentParent is not container, if currentParent matches selectorText, it is returned. -- Garrett @xkit ChordCycles.com garretts.github.io
Received on Monday, 6 January 2014 18:13:44 UTC