diff --git a/Userland/Libraries/LibWeb/CSS/SelectorEngine.cpp b/Userland/Libraries/LibWeb/CSS/SelectorEngine.cpp index eb14395241..75861ad37d 100644 --- a/Userland/Libraries/LibWeb/CSS/SelectorEngine.cpp +++ b/Userland/Libraries/LibWeb/CSS/SelectorEngine.cpp @@ -354,7 +354,7 @@ static inline bool matches(CSS::Selector::SimpleSelector const& component, DOM:: case CSS::Selector::SimpleSelector::Type::Id: return component.name() == element.attribute(HTML::AttributeNames::id).view(); case CSS::Selector::SimpleSelector::Type::Class: - return element.has_class(component.name().bytes_as_string_view()); + 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 (element.document().document_type() == DOM::Document::Type::HTML) diff --git a/Userland/Libraries/LibWeb/DOM/Document.cpp b/Userland/Libraries/LibWeb/DOM/Document.cpp index 83556273a9..7ccf729904 100644 --- a/Userland/Libraries/LibWeb/DOM/Document.cpp +++ b/Userland/Libraries/LibWeb/DOM/Document.cpp @@ -1030,9 +1030,9 @@ JS::NonnullGCPtr Document::get_elements_by_name(DeprecatedString JS::NonnullGCPtr Document::get_elements_by_class_name(DeprecatedFlyString const& class_names) { - Vector list_of_class_names; + Vector list_of_class_names; for (auto& name : class_names.view().split_view(' ')) { - list_of_class_names.append(name); + list_of_class_names.append(FlyString::from_utf8(name).release_value_but_fixme_should_propagate_errors()); } return HTMLCollection::create(*this, [list_of_class_names = move(list_of_class_names), quirks_mode = document().in_quirks_mode()](Element const& element) { for (auto& name : list_of_class_names) { diff --git a/Userland/Libraries/LibWeb/DOM/Element.cpp b/Userland/Libraries/LibWeb/DOM/Element.cpp index 8975b21112..9bb5861080 100644 --- a/Userland/Libraries/LibWeb/DOM/Element.cpp +++ b/Userland/Libraries/LibWeb/DOM/Element.cpp @@ -271,7 +271,7 @@ Vector Element::get_attribute_names() const return names; } -bool Element::has_class(DeprecatedFlyString const& class_name, CaseSensitivity case_sensitivity) const +bool Element::has_class(FlyString const& class_name, CaseSensitivity case_sensitivity) const { if (case_sensitivity == CaseSensitivity::CaseSensitive) { return any_of(m_classes, [&](auto& it) { @@ -279,7 +279,7 @@ bool Element::has_class(DeprecatedFlyString const& class_name, CaseSensitivity c }); } else { return any_of(m_classes, [&](auto& it) { - return it.equals_ignoring_case(class_name); + return it.equals_ignoring_ascii_case(class_name); }); } } @@ -347,7 +347,7 @@ void Element::parse_attribute(DeprecatedFlyString const& name, DeprecatedString m_classes.clear(); m_classes.ensure_capacity(new_classes.size()); for (auto& new_class : new_classes) { - m_classes.unchecked_append(new_class); + m_classes.unchecked_append(FlyString::from_utf8(new_class).release_value_but_fixme_should_propagate_errors()); } if (m_class_list) m_class_list->associated_attribute_changed(value); @@ -580,9 +580,9 @@ bool Element::is_active() const JS::NonnullGCPtr Element::get_elements_by_class_name(DeprecatedFlyString const& class_names) { - Vector list_of_class_names; + Vector list_of_class_names; for (auto& name : class_names.view().split_view_if(Infra::is_ascii_whitespace)) { - list_of_class_names.append(name); + list_of_class_names.append(FlyString::from_utf8(name).release_value_but_fixme_should_propagate_errors()); } return HTMLCollection::create(*this, [list_of_class_names = move(list_of_class_names), quirks_mode = document().in_quirks_mode()](Element const& element) { for (auto& name : list_of_class_names) { diff --git a/Userland/Libraries/LibWeb/DOM/Element.h b/Userland/Libraries/LibWeb/DOM/Element.h index 86a5104843..e64d1de6dc 100644 --- a/Userland/Libraries/LibWeb/DOM/Element.h +++ b/Userland/Libraries/LibWeb/DOM/Element.h @@ -101,8 +101,8 @@ public: } } - bool has_class(DeprecatedFlyString const&, CaseSensitivity = CaseSensitivity::CaseSensitive) const; - Vector const& class_names() const { return m_classes; } + bool has_class(FlyString const&, CaseSensitivity = CaseSensitivity::CaseSensitive) const; + Vector const& class_names() const { return m_classes; } virtual void apply_presentational_hints(CSS::StyleProperties&) const { } virtual void parse_attribute(DeprecatedFlyString const& name, DeprecatedString const& value); @@ -284,7 +284,7 @@ private: RefPtr m_computed_css_values; HashMap m_custom_properties; - Vector m_classes; + Vector m_classes; Array, to_underlying(CSS::Selector::PseudoElement::PseudoElementCount)> m_pseudo_element_nodes; };