Skip to content

Commit

Permalink
[css-properties-values-api] Accept any value through setProperty.
Browse files Browse the repository at this point in the history
According to a recent spec change, the syntax of a registered custom
property must be ignored until computed-value time. This means that
setProperty may not inspect the PropertyRegistry and reject values
based on that.

This CL also removes the PropertyRegistry parameter in many places, to
avoid incorrectly using it in the future.

Bug: 641877
Change-Id: I99c58775e800500862378420118d81fe3186e739
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1714590
Reviewed-by: Rune Lillesveen <futhark@chromium.org>
Commit-Queue: Anders Hartvoll Ruud <andruud@chromium.org>
Cr-Commit-Position: refs/heads/master@{#680388}
  • Loading branch information
andruud authored and chromium-wpt-export-bot committed Jul 24, 2019
1 parent 1fad9be commit b0b4f38
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions css/css-properties-values-api/registered-property-cssom.html
Expand Up @@ -52,9 +52,9 @@
test(function() {
inlineStyle.setProperty('--length', 'hi');
inlineStyle.setProperty('--color', '20');
assert_equals(inlineStyle.getPropertyValue('--length'), '5');
assert_equals(inlineStyle.getPropertyValue('--color'), 'hello');
}, "Values not matching the registered type can't be set");
assert_equals(inlineStyle.getPropertyValue('--length'), 'hi');
assert_equals(inlineStyle.getPropertyValue('--color'), '20');
}, "Values not matching the registered type can still be set");

test(function() {
inlineStyle.removeProperty('--length');
Expand All @@ -66,8 +66,9 @@
}, "Values can be removed from inline styles");

test(function() {
sheetStyle.setProperty('--length', 'banana'); // Invalid, no change
assert_equals(computedStyle.getPropertyValue('--length'), '10px');
// 'banana' is not a valid <length>, but still accepted.
sheetStyle.setProperty('--length', 'banana');
assert_equals(computedStyle.getPropertyValue('--length'), '0px');
sheetStyle.setProperty('--length', '20px');
assert_equals(computedStyle.getPropertyValue('--length'), '20px');
sheetStyle.setProperty('--length', 'initial');
Expand Down

0 comments on commit b0b4f38

Please sign in to comment.