Skip to content

Truly independent web browser

LibWeb: Reify a single-item StyleValueList as its item

Andreas Klingf8a17251e156
diff --git a/Libraries/LibWeb/CSS/StyleValues/StyleValueList.cpp b/Libraries/LibWeb/CSS/StyleValues/StyleValueList.cpp
index 12136efa807..6844c12db55 100644
--- a/Libraries/LibWeb/CSS/StyleValues/StyleValueList.cpp
+++ b/Libraries/LibWeb/CSS/StyleValues/StyleValueList.cpp
@@ -49,6 +49,11 @@ GC::Ref<CSSStyleValue> StyleValueList::reify(Utf16FlyString const& associated_pr
return transform_list.as_nonnull();
}
+ // NB: A list with a single item, such as `text-decoration-line: underline`, is that item on its own. Reify the
+ // item, so that a single keyword reifies as a CSSKeywordValue.
+ if (values.size() == 1)
+ return values.first()->reify(associated_property);
+
// NB: Otherwise, there isn't an equivalent CSSStyleValue for StyleValueList, so just use the default.
return default_reify(associated_property);
}
diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/white-space.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/white-space.txt
index 8fb378834d1..e255abdaee1 100644
--- a/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/white-space.txt
+++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/white-space.txt
@@ -2,8 +2,7 @@ Harness status: OK
Found 144 tests
-141 Pass
-3 Fail
+144 Pass
Pass Can set 'white-space-collapse' to CSS-wide keywords: initial
Pass Can set 'white-space-collapse' to CSS-wide keywords: inherit
Pass Can set 'white-space-collapse' to CSS-wide keywords: unset
@@ -115,9 +114,9 @@ Pass Can set 'white-space-trim' to CSS-wide keywords: unset
Pass Can set 'white-space-trim' to CSS-wide keywords: revert
Pass Can set 'white-space-trim' to var() references: var(--A)
Pass Can set 'white-space-trim' to the 'none' keyword: none
-Fail Can set 'white-space-trim' to the 'discard-before' keyword: discard-before
-Fail Can set 'white-space-trim' to the 'discard-after' keyword: discard-after
-Fail Can set 'white-space-trim' to the 'discard-inner' keyword: discard-inner
+Pass Can set 'white-space-trim' to the 'discard-before' keyword: discard-before
+Pass Can set 'white-space-trim' to the 'discard-after' keyword: discard-after
+Pass Can set 'white-space-trim' to the 'discard-inner' keyword: discard-inner
Pass Setting 'white-space-trim' to a length: 0px throws TypeError
Pass Setting 'white-space-trim' to a length: -3.14em throws TypeError
Pass Setting 'white-space-trim' to a length: 3.14cm throws TypeError