diff --git a/Libraries/LibWeb/DOM/Document.cpp b/Libraries/LibWeb/DOM/Document.cpp index a92bcb0dc4a..73bf30fce72 100644 --- a/Libraries/LibWeb/DOM/Document.cpp +++ b/Libraries/LibWeb/DOM/Document.cpp @@ -1753,9 +1753,11 @@ void Document::invalidate_style_for_elements_affected_by_hover_change(Node& old_ bool selector_matched = false; if (SelectorEngine::matches(selector, element, {}, context, {})) selector_matched = true; - if (element.has_pseudo_elements()) { + if (element.has_pseudo_element(CSS::Selector::PseudoElement::Type::Before)) { if (SelectorEngine::matches(selector, element, {}, context, CSS::Selector::PseudoElement::Type::Before)) selector_matched = true; + } + if (element.has_pseudo_element(CSS::Selector::PseudoElement::Type::After)) { if (SelectorEngine::matches(selector, element, {}, context, CSS::Selector::PseudoElement::Type::After)) selector_matched = true; } diff --git a/Libraries/LibWeb/DOM/Element.h b/Libraries/LibWeb/DOM/Element.h index fad2b788f01..0b728d24708 100644 --- a/Libraries/LibWeb/DOM/Element.h +++ b/Libraries/LibWeb/DOM/Element.h @@ -273,6 +273,7 @@ public: void set_pseudo_element_node(Badge, CSS::Selector::PseudoElement::Type, GC::Ptr); GC::Ptr get_pseudo_element_node(CSS::Selector::PseudoElement::Type) const; + bool has_pseudo_element(CSS::Selector::PseudoElement::Type) const; bool has_pseudo_elements() const; void clear_pseudo_element_nodes(Badge); void serialize_pseudo_elements_as_json(JsonArraySerializer& children_array) const; @@ -589,6 +590,15 @@ inline bool Element::has_class(FlyString const& class_name, CaseSensitivity case }); } +inline bool Element::has_pseudo_element(CSS::Selector::PseudoElement::Type type) const +{ + if (!m_pseudo_element_data) + return false; + if (!CSS::Selector::PseudoElement::is_known_pseudo_element_type(type)) + return false; + return m_pseudo_element_data->at(to_underlying(type)).layout_node; +} + WebIDL::ExceptionOr validate_and_extract(JS::Realm&, Optional namespace_, FlyString const& qualified_name); }