diff options
author | Simon Wanner <simon+git@skyrising.xyz> | 2023-03-20 23:45:12 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2023-03-21 10:45:19 +0100 |
commit | d55373067d16fef61d4702dbcb78f266a8134cfc (patch) | |
tree | 92ac2c921fcab1625074a3123efb17423064fe97 /Userland/Libraries/LibWeb | |
parent | c8ebacb1c9f85070e6881c585978336e718dd6cc (diff) | |
download | serenity-d55373067d16fef61d4702dbcb78f266a8134cfc.zip |
LibWeb: Pass scope in Element::matches
Diffstat (limited to 'Userland/Libraries/LibWeb')
-rw-r--r-- | Userland/Libraries/LibWeb/DOM/Element.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/Userland/Libraries/LibWeb/DOM/Element.cpp b/Userland/Libraries/LibWeb/DOM/Element.cpp index 7b947883b5..83c3ce79c2 100644 --- a/Userland/Libraries/LibWeb/DOM/Element.cpp +++ b/Userland/Libraries/LibWeb/DOM/Element.cpp @@ -532,13 +532,17 @@ JS::GCPtr<ShadowRoot> Element::shadow_root() const // https://dom.spec.whatwg.org/#dom-element-matches WebIDL::ExceptionOr<bool> Element::matches(StringView selectors) const { + // 1. Let s be the result of parse a selector from selectors. auto maybe_selectors = parse_selector(CSS::Parser::ParsingContext(static_cast<ParentNode&>(const_cast<Element&>(*this))), selectors); + + // 2. If s is failure, then throw a "SyntaxError" DOMException. if (!maybe_selectors.has_value()) return WebIDL::SyntaxError::create(realm(), "Failed to parse selector"); + // 3. If the result of match a selector against an element, using s, this, and scoping root this, returns success, then return true; otherwise, return false. auto sel = maybe_selectors.value(); for (auto& s : sel) { - if (SelectorEngine::matches(s, *this)) + if (SelectorEngine::matches(s, *this, {}, static_cast<ParentNode const*>(this))) return true; } return false; |