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.
This commit is contained in:
parent
6805baeedd
commit
48c54e6796
Notes:
sideshowbarker
2024-07-17 09:43:46 +09:00
Author: https://github.com/networkException Commit: https://github.com/SerenityOS/serenity/commit/48c54e6796 Pull-request: https://github.com/SerenityOS/serenity/pull/14472 Reviewed-by: https://github.com/awesomekling Reviewed-by: https://github.com/linusg ✅ Reviewed-by: https://github.com/nico
1 changed files with 3 additions and 0 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Reference in a new issue