mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-30 03:20:28 +00:00
LibWeb: Match class selectors case insensitively in quirks mode
This align our implementation with the CSSWG Selectors Level 4 specification.
This commit is contained in:
parent
e2c9e34050
commit
82ed253477
Notes:
github-actions[bot]
2024-08-03 14:46:10 +00:00
Author: https://github.com/tcl3 Commit: https://github.com/LadybirdBrowser/ladybird/commit/82ed2534776 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/937
3 changed files with 22 additions and 4 deletions
|
@ -0,0 +1 @@
|
||||||
|
ParentNode.querySelector matches class selectors case-insensitively in quirks mode: true
|
|
@ -0,0 +1,9 @@
|
||||||
|
<!-- Quirks mode -->
|
||||||
|
<script src="include.js"></script>
|
||||||
|
<div class="tEsT"></div>
|
||||||
|
<script>
|
||||||
|
test(() => {
|
||||||
|
let divElement = document.querySelector(".test");
|
||||||
|
println(`ParentNode.querySelector matches class selectors case-insensitively in quirks mode: ${divElement instanceof Element}`);
|
||||||
|
});
|
||||||
|
</script>
|
|
@ -702,8 +702,12 @@ static inline bool matches(CSS::Selector::SimpleSelector const& component, Optio
|
||||||
}
|
}
|
||||||
case CSS::Selector::SimpleSelector::Type::Id:
|
case CSS::Selector::SimpleSelector::Type::Id:
|
||||||
return component.name() == element.id();
|
return component.name() == element.id();
|
||||||
case CSS::Selector::SimpleSelector::Type::Class:
|
case CSS::Selector::SimpleSelector::Type::Class: {
|
||||||
return element.has_class(component.name());
|
// Class selectors are matched case insensitively in quirks mode.
|
||||||
|
// See: https://drafts.csswg.org/selectors-4/#class-html
|
||||||
|
auto case_sensitivity = element.document().in_quirks_mode() ? CaseSensitivity::CaseInsensitive : CaseSensitivity::CaseSensitive;
|
||||||
|
return element.has_class(component.name(), case_sensitivity);
|
||||||
|
}
|
||||||
case CSS::Selector::SimpleSelector::Type::Attribute:
|
case CSS::Selector::SimpleSelector::Type::Attribute:
|
||||||
return matches_attribute(component.attribute(), style_sheet_for_rule, element);
|
return matches_attribute(component.attribute(), style_sheet_for_rule, element);
|
||||||
case CSS::Selector::SimpleSelector::Type::PseudoClass:
|
case CSS::Selector::SimpleSelector::Type::PseudoClass:
|
||||||
|
@ -788,8 +792,12 @@ static bool fast_matches_simple_selector(CSS::Selector::SimpleSelector const& si
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return matches_namespace(simple_selector.qualified_name(), element, style_sheet_for_rule);
|
return matches_namespace(simple_selector.qualified_name(), element, style_sheet_for_rule);
|
||||||
case CSS::Selector::SimpleSelector::Type::Class:
|
case CSS::Selector::SimpleSelector::Type::Class: {
|
||||||
return element.has_class(simple_selector.name());
|
// Class selectors are matched case insensitively in quirks mode.
|
||||||
|
// See: https://drafts.csswg.org/selectors-4/#class-html
|
||||||
|
auto case_sensitivity = element.document().in_quirks_mode() ? CaseSensitivity::CaseInsensitive : CaseSensitivity::CaseSensitive;
|
||||||
|
return element.has_class(simple_selector.name(), case_sensitivity);
|
||||||
|
}
|
||||||
case CSS::Selector::SimpleSelector::Type::Id:
|
case CSS::Selector::SimpleSelector::Type::Id:
|
||||||
return simple_selector.name() == element.id();
|
return simple_selector.name() == element.id();
|
||||||
case CSS::Selector::SimpleSelector::Type::Attribute:
|
case CSS::Selector::SimpleSelector::Type::Attribute:
|
||||||
|
|
Loading…
Reference in a new issue