LibWeb/DOM: Don't crash getting custom properties from invalid pseudos

This commit is contained in:
Sam Atkins 2025-06-25 16:34:36 +01:00 committed by Tim Ledbetter
commit 97ad1ea7e0
Notes: github-actions[bot] 2025-07-09 15:46:13 +00:00

View file

@ -3026,10 +3026,13 @@ void Element::set_custom_properties(Optional<CSS::PseudoElement> pseudo_element,
HashMap<FlyString, CSS::StyleProperty> const& Element::custom_properties(Optional<CSS::PseudoElement> pseudo_element) const
{
static HashMap<FlyString, CSS::StyleProperty> s_empty_custom_properties;
if (!pseudo_element.has_value())
return m_custom_properties;
VERIFY(CSS::Selector::PseudoElementSelector::is_known_pseudo_element_type(pseudo_element.value()));
if (!CSS::Selector::PseudoElementSelector::is_known_pseudo_element_type(pseudo_element.value()))
return s_empty_custom_properties;
return ensure_pseudo_element(pseudo_element.value()).custom_properties();
}