diff --git a/Libraries/LibWeb/CSS/ResolvedCSSStyleDeclaration.cpp b/Libraries/LibWeb/CSS/ResolvedCSSStyleDeclaration.cpp index e062224c9a4..156a5f47f60 100644 --- a/Libraries/LibWeb/CSS/ResolvedCSSStyleDeclaration.cpp +++ b/Libraries/LibWeb/CSS/ResolvedCSSStyleDeclaration.cpp @@ -604,7 +604,16 @@ Optional ResolvedCSSStyleDeclaration::property(PropertyID propert Optional ResolvedCSSStyleDeclaration::custom_property(FlyString const& name) const { const_cast(m_element->document()).update_style(); - return m_element->custom_properties(m_pseudo_element).get(name); + + auto const* element_to_check = m_element.ptr(); + while (element_to_check) { + if (auto property = element_to_check->custom_properties(m_pseudo_element).get(name); property.has_value()) + return *property; + + element_to_check = element_to_check->parent_element(); + } + + return {}; } static WebIDL::ExceptionOr cannot_modify_computed_property_error(JS::Realm& realm) diff --git a/Tests/LibWeb/Text/expected/custom-property-from-parent.txt b/Tests/LibWeb/Text/expected/custom-property-from-parent.txt new file mode 100644 index 00000000000..235dd81b746 --- /dev/null +++ b/Tests/LibWeb/Text/expected/custom-property-from-parent.txt @@ -0,0 +1 @@ +PASS: #19db6e \ No newline at end of file diff --git a/Tests/LibWeb/Text/input/custom-property-from-parent.html b/Tests/LibWeb/Text/input/custom-property-from-parent.html new file mode 100644 index 00000000000..cdbdd9ac451 --- /dev/null +++ b/Tests/LibWeb/Text/input/custom-property-from-parent.html @@ -0,0 +1,13 @@ + + + +