mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-28 02:27:19 +02:00
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
This commit is contained in:
Notes:
sideshowbarker
2024-07-17 02:59:43 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/89ba7246dd Pull-request: https://github.com/SerenityOS/serenity/pull/18755
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user