Skip to content

Commit 6736a31

Browse files
committed
[@Property] Failing to provide intialValue in registerProperty with non-universal syntax should throw
https://bugs.webkit.org/show_bug.cgi?id=250556 <rdar://problem/104254311> Reviewed by Simon Fraser. * LayoutTests/imported/w3c/web-platform-tests/css/css-properties-values-api/register-property-expected.txt: * Source/WebCore/css/DOMCSSRegisterCustomProperty.cpp: (WebCore::DOMCSSRegisterCustomProperty::registerProperty): Throw is needed. Canonical link: https://commits.webkit.org/258909@main
1 parent b922a9d commit 6736a31

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

LayoutTests/imported/w3c/web-platform-tests/css/css-properties-values-api/register-property-expected.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
PASS registerProperty requires a Dictionary type
33
PASS registerProperty requires a name matching <custom-property-name>
4-
FAIL registerProperty only allows omitting initialValue if syntax is '*' assert_throws_dom: function "() => CSS.registerProperty({name: '--syntax-test-3', syntax: 'length', inherits: false})" did not throw
4+
PASS registerProperty only allows omitting initialValue if syntax is '*'
55
PASS registerProperty fails for an already registered property
66
PASS registerProperty requires inherits
77
PASS Registering a property should not cause a transition

Source/WebCore/css/DOMCSSRegisterCustomProperty.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ ExceptionOr<void> DOMCSSRegisterCustomProperty::registerProperty(Document& docum
5151
if (!syntax)
5252
return Exception { SyntaxError, "Invalid property syntax definition."_s };
5353

54+
if (!syntax->isUniversal() && descriptor.initialValue.isNull())
55+
return Exception { SyntaxError, "An initial value is mandatory except for the '*' syntax."_s };
56+
5457
RefPtr<CSSCustomPropertyValue> initialValue;
5558
if (!descriptor.initialValue.isNull()) {
5659
CSSTokenizer tokenizer(descriptor.initialValue);

0 commit comments

Comments
 (0)