mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-26 12:17:52 +00:00
LibWeb: Match attribute selectors case insensitively in XML documents
The values of attribute selectors are now compared case insensitively by default if the attribute's document is not a HTML document, or the element is not in the HTML namespace.
This commit is contained in:
parent
c422518792
commit
00f03f3e90
Notes:
github-actions[bot]
2024-08-19 07:04:16 +00:00
Author: https://github.com/tcl3
Commit: 00f03f3e90
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1116
5 changed files with 54 additions and 62 deletions
|
@ -77,56 +77,6 @@ public:
|
|||
|
||||
[[nodiscard]] LengthOrCalculated parse_as_sizes_attribute();
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/semantics-other.html#case-sensitivity-of-selectors
|
||||
static constexpr Array case_insensitive_html_attributes = {
|
||||
"accept"sv,
|
||||
"accept-charset"sv,
|
||||
"align"sv,
|
||||
"alink"sv,
|
||||
"axis"sv,
|
||||
"bgcolor"sv,
|
||||
"charset"sv,
|
||||
"checked"sv,
|
||||
"clear"sv,
|
||||
"codetype"sv,
|
||||
"color"sv,
|
||||
"compact"sv,
|
||||
"declare"sv,
|
||||
"defer"sv,
|
||||
"dir"sv,
|
||||
"direction"sv,
|
||||
"disabled"sv,
|
||||
"enctype"sv,
|
||||
"face"sv,
|
||||
"frame"sv,
|
||||
"hreflang"sv,
|
||||
"http-equiv"sv,
|
||||
"lang"sv,
|
||||
"language"sv,
|
||||
"link"sv,
|
||||
"media"sv,
|
||||
"method"sv,
|
||||
"multiple"sv,
|
||||
"nohref"sv,
|
||||
"noresize"sv,
|
||||
"noshade"sv,
|
||||
"nowrap"sv,
|
||||
"readonly"sv,
|
||||
"rel"sv,
|
||||
"rev"sv,
|
||||
"rules"sv,
|
||||
"scope"sv,
|
||||
"scrolling"sv,
|
||||
"selected"sv,
|
||||
"shape"sv,
|
||||
"target"sv,
|
||||
"text"sv,
|
||||
"type"sv,
|
||||
"valign"sv,
|
||||
"valuetype"sv,
|
||||
"vlink"sv,
|
||||
};
|
||||
|
||||
private:
|
||||
Parser(ParsingContext const&, Vector<Token>);
|
||||
|
||||
|
|
|
@ -260,15 +260,8 @@ Parser::ParseErrorOr<Selector::SimpleSelector> Parser::parse_attribute_simple_se
|
|||
.type = Selector::SimpleSelector::Type::Attribute,
|
||||
.value = Selector::SimpleSelector::Attribute {
|
||||
.match_type = Selector::SimpleSelector::Attribute::MatchType::HasAttribute,
|
||||
// FIXME: Case-sensitivity is defined by the document language.
|
||||
// HTML is insensitive with attribute names, and our code generally assumes
|
||||
// they are converted to lowercase, so we do that here too. If we want to be
|
||||
// correct with XML later, we'll need to keep the original case and then do
|
||||
// a case-insensitive compare later.
|
||||
.qualified_name = qualified_name,
|
||||
.case_type = case_insensitive_html_attributes.contains_slow(qualified_name.name.lowercase_name)
|
||||
? Selector::SimpleSelector::Attribute::CaseType::CaseInsensitiveMatch
|
||||
: Selector::SimpleSelector::Attribute::CaseType::DefaultMatch,
|
||||
.case_type = Selector::SimpleSelector::Attribute::CaseType::DefaultMatch,
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue