mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-30 12:49:19 +00:00
LibWeb: Change Element::closest() to check if any of selector matches
...instead of checking if all selectors match an element. Fixes bug reduced from GitHub's "new issue" page.
This commit is contained in:
parent
9bf29356a2
commit
d5c6e45dca
Notes:
sideshowbarker
2024-07-17 06:40:21 +09:00
Author: https://github.com/kalenikaliaksandr
Commit: d5c6e45dca
Pull-request: https://github.com/SerenityOS/serenity/pull/23680
3 changed files with 15 additions and 4 deletions
|
@ -678,11 +678,11 @@ WebIDL::ExceptionOr<DOM::Element const*> Element::closest(StringView selectors)
|
|||
|
||||
auto matches_selectors = [this](CSS::SelectorList const& selector_list, Element const* element) {
|
||||
// 4. For each element in elements, if match a selector against an element, using s, element, and scoping root this, returns success, return element.
|
||||
for (auto& selector : selector_list) {
|
||||
if (!SelectorEngine::matches(selector, {}, *element, {}, this))
|
||||
return false;
|
||||
for (auto const& selector : selector_list) {
|
||||
if (SelectorEngine::matches(selector, {}, *element, {}, this))
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
return false;
|
||||
};
|
||||
|
||||
auto const selector_list = maybe_selectors.release_value();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue