Chromium Code Reviews

Unified Diff: Source/core/dom/Element.cpp

Issue 701723007: Adding Element.closest() API (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Index: Source/core/dom/Element.cpp
diff --git a/Source/core/dom/Element.cpp b/Source/core/dom/Element.cpp
index 023c8502de685fe77ee043a506c635694f3f268a..5877c81cc497b088872d9e214e07f35ecc22bff3 100644
--- a/Source/core/dom/Element.cpp
+++ b/Source/core/dom/Element.cpp
@@ -2532,6 +2532,14 @@ bool Element::matches(const String& selectors, ExceptionState& exceptionState)
return selectorQuery->matches(*this);
}
+Element* Element::closest(const String& selectors, ExceptionState& exceptionState)
+{
+ SelectorQuery* selectorQuery = document().selectorQueryCache().add(AtomicString(selectors), document(), exceptionState);
+ if (!selectorQuery)
+ return nullptr;
+ return selectorQuery->closest(*this);
+}
+
DOMTokenList& Element::classList()
{
ElementRareData& rareData = ensureElementRareData();

Powered by Google App Engine