diff --git a/dom.bs b/dom.bs index 0e351d14e..342f95291 100644 --- a/dom.bs +++ b/dom.bs @@ -3075,6 +3075,53 @@ steps: +
+interface mixin TreeNode { + [Unscopable] Element? closest(DOMString selectors); +}; +Element includes TreeNode; +CharacterData includes TreeNode; +Document includes TreeNode; +DocumentType includes TreeNode; +DocumentFragment includes TreeNode; ++ +
node . {{closest(selectors)}}
+ Returns the first (starting at node) inclusive ancestor + that matches selectors, and null otherwise. +
The
+closest(selectors)
method, when invoked, must run these steps:
+
+
Let s be the result of parse a selector from selectors. + [[!SELECTORS4]] + +
If s is failure, throw a "{{SyntaxError!!exception}}" {{DOMException}}. + +
Let elements be this's inclusive ancestors that are + elements, in reverse tree order. + +
If elements is not empty, then: + +
Let scopeElement be the first element in elements. + +
For each element in elements, + if match a selector against an element, using s, element, + and :scope element scopeElement, returns success, return element. + [[!SELECTORS4]] +
Return null. +
@@ -5861,7 +5908,6 @@ interface Element : Node { ShadowRoot attachShadow(ShadowRootInit init); readonly attribute ShadowRoot? shadowRoot; - Element? closest(DOMString selectors); boolean matches(DOMString selectors); boolean webkitMatchesSelector(DOMString selectors); // historical alias of .matches @@ -6776,42 +6822,12 @@ steps:
element . {{closest(selectors)}}
- element . {{matches(selectors)}}
closest(selectors)
-method, when invoked, must run these steps:
-
-matches(selectors)
and
webkitMatchesSelector(selectors)
methods, when
invoked, must run these steps: