summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornetworkException <git@nwex.de>2022-07-03 20:54:13 +0200
committerLinus Groh <mail@linusgroh.de>2022-07-04 12:39:48 +0200
commit48c54e6796230dc0ad6100b84d3b4b71390c2a65 (patch)
treec67972a4683da98f442c7dcc6f5b669199001b6a
parent6805baeedd96499b8bcba5dc6ae3d2c7e21505cd (diff)
downloadserenity-48c54e6796230dc0ad6100b84d3b4b71390c2a65.zip
LibWeb: Use lowercase type selectors to match against html elements
Previously we would fail to match a selector like "NAV" against a <nav> html element. Note that the strings must be identical in XML Documents.
-rw-r--r--Userland/Libraries/LibWeb/CSS/SelectorEngine.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/Userland/Libraries/LibWeb/CSS/SelectorEngine.cpp b/Userland/Libraries/LibWeb/CSS/SelectorEngine.cpp
index 43794e2f6b..d31b7ad564 100644
--- a/Userland/Libraries/LibWeb/CSS/SelectorEngine.cpp
+++ b/Userland/Libraries/LibWeb/CSS/SelectorEngine.cpp
@@ -341,6 +341,9 @@ static inline bool matches(CSS::Selector::SimpleSelector const& component, DOM::
case CSS::Selector::SimpleSelector::Type::Class:
return element.has_class(component.name());
case CSS::Selector::SimpleSelector::Type::TagName:
+ // See https://html.spec.whatwg.org/multipage/semantics-other.html#case-sensitivity-of-selectors
+ if (is<HTML::HTMLElement>(element) && element.document().document_type() != DOM::Document::Type::XML)
+ return component.name().equals_ignoring_case(element.local_name());
return component.name() == element.local_name();
case CSS::Selector::SimpleSelector::Type::Attribute:
return matches_attribute(component.attribute(), element);