From 7e2308d290b1b197e6c5246486d26a425f1707e0 Mon Sep 17 00:00:00 2001 From: Aliaksandr Kalenik Date: Sun, 21 Jan 2024 20:00:52 +0100 Subject: [PATCH] LibWeb: Treat null as empty string in CSSStyleDeclaration::internal_set Spec defines `[LegacyNullToEmptyString]` on `value` argument of `setProperty` but since `internal_set` calls `setProperty` directly instead of using IDL generated binding, we need to make sure that null is treated as empty string. Fixes items grid loading on https://d.rsms.me/stuff/ --- Tests/LibWeb/Layout/expected/misc/set-display-null.txt | 9 +++++++++ Tests/LibWeb/Layout/input/misc/set-display-null.html | 9 +++++++++ Userland/Libraries/LibWeb/CSS/CSSStyleDeclaration.cpp | 2 +- 3 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 Tests/LibWeb/Layout/expected/misc/set-display-null.txt create mode 100644 Tests/LibWeb/Layout/input/misc/set-display-null.html diff --git a/Tests/LibWeb/Layout/expected/misc/set-display-null.txt b/Tests/LibWeb/Layout/expected/misc/set-display-null.txt new file mode 100644 index 0000000000..f4a0b262c1 --- /dev/null +++ b/Tests/LibWeb/Layout/expected/misc/set-display-null.txt @@ -0,0 +1,9 @@ +Viewport <#document> at (0,0) content-size 800x600 children: not-inline + BlockContainer at (0,0) content-size 800x116 [BFC] children: not-inline + BlockContainer at (8,8) content-size 784x100 children: not-inline + BlockContainer at (8,8) content-size 100x100 children: not-inline + +ViewportPaintable (Viewport<#document>) [0,0 800x600] + PaintableWithLines (BlockContainer) [0,0 800x116] + PaintableWithLines (BlockContainer) [8,8 784x100] + PaintableWithLines (BlockContainer
#box) [8,8 100x100] diff --git a/Tests/LibWeb/Layout/input/misc/set-display-null.html b/Tests/LibWeb/Layout/input/misc/set-display-null.html new file mode 100644 index 0000000000..8e099afc86 --- /dev/null +++ b/Tests/LibWeb/Layout/input/misc/set-display-null.html @@ -0,0 +1,9 @@ +
\ No newline at end of file diff --git a/Userland/Libraries/LibWeb/CSS/CSSStyleDeclaration.cpp b/Userland/Libraries/LibWeb/CSS/CSSStyleDeclaration.cpp index 792922821e..5ebbe1c368 100644 --- a/Userland/Libraries/LibWeb/CSS/CSSStyleDeclaration.cpp +++ b/Userland/Libraries/LibWeb/CSS/CSSStyleDeclaration.cpp @@ -432,7 +432,7 @@ JS::ThrowCompletionOr CSSStyleDeclaration::internal_set(JS::PropertyKey co if (property_id == CSS::PropertyID::Invalid) return Base::internal_set(name, value, receiver, cacheable_metadata); - auto css_text = TRY(value.to_string(vm)); + auto css_text = value.is_null() ? String {} : TRY(value.to_string(vm)); TRY(Bindings::throw_dom_exception_if_needed(vm, [&] { return set_property(property_id, css_text); })); return true;