summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2023-05-10 15:33:10 +0200
committerAndreas Kling <kling@serenityos.org>2023-05-10 17:27:07 +0200
commit89ba7246dd07f3ec1812736be43606c08d45daef (patch)
tree1fbb04d70c0ee2ef0ef99dc338bd0dd908697114 /Userland
parent4005793e79b42e7ff042dd74ebe57aa869c92ec2 (diff)
downloadserenity-89ba7246dd07f3ec1812736be43606c08d45daef.zip
LibWeb: Don't resolve CSS property values for unconnected elements
While it's possible to getComputedStyle() on an unconnected element, the resulting object is not supposed to have any values, since we can't resolve style without a document root anyway. This fixes a crash on https://bandcamp.com
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Libraries/LibWeb/CSS/ResolvedCSSStyleDeclaration.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/Userland/Libraries/LibWeb/CSS/ResolvedCSSStyleDeclaration.cpp b/Userland/Libraries/LibWeb/CSS/ResolvedCSSStyleDeclaration.cpp
index c1cc9fc703..99a2987d8d 100644
--- a/Userland/Libraries/LibWeb/CSS/ResolvedCSSStyleDeclaration.cpp
+++ b/Userland/Libraries/LibWeb/CSS/ResolvedCSSStyleDeclaration.cpp
@@ -666,6 +666,11 @@ ErrorOr<RefPtr<StyleValue const>> ResolvedCSSStyleDeclaration::style_value_for_p
Optional<StyleProperty> ResolvedCSSStyleDeclaration::property(PropertyID property_id) const
{
+ // https://www.w3.org/TR/cssom-1/#dom-window-getcomputedstyle
+ // NOTE: This is a partial enforcement of step 5 ("If elt is connected, ...")
+ if (!m_element->is_connected())
+ return {};
+
if (CSS::property_affects_layout(property_id)) {
const_cast<DOM::Document&>(m_element->document()).update_layout();
} else {