Skip to content

Commit

Permalink
[css-properties-values-api] CSS.supports(property, value) behavior.
Browse files Browse the repository at this point in the history
The two-parameter version of CSS.supports should return false if the
value does not parse for the registered syntax of the property.

BUG=641877
R=futhark@chromium.org

Change-Id: I7a3ccbbd8ad465132bb44348919db19e837b5dd7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1604268
Reviewed-by: Rune Lillesveen <futhark@chromium.org>
Commit-Queue: Anders Hartvoll Ruud <andruud@chromium.org>
Cr-Commit-Position: refs/heads/master@{#659919}
  • Loading branch information
andruud authored and chromium-wpt-export-bot committed May 15, 2019
1 parent d04f026 commit d7afcb8
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions css/css-properties-values-api/conditional-rules.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<!DOCTYPE html>
<link rel="help" href="https://drafts.css-houdini.org/css-properties-values-api-1/#conditional-rules" />
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>

<script>
CSS.registerProperty({
name: '--length',
syntax: '<length>',
initialValue: '0px',
inherits: false
});
</script>

<style>
#target { color: red; }
@supports(--length: green) {
#target { color: rgb(1, 2, 3); }
}
</style>

<div id=target></div>

<script>

test(function() {
let cs = getComputedStyle(target);
assert_equals(cs.getPropertyValue('color'), 'rgb(1, 2, 3)');
}, '@supports should ignore registered syntax');

test(function() {
assert_true(CSS.supports('--length: red'));
assert_true(CSS.supports('--length: 10px'));
assert_true(CSS.supports('--length: anything, really'));
}, 'CSS.supports(conditionText) should ignore registered syntax');

test(function() {
assert_false(CSS.supports('--length', 'red'));
assert_true(CSS.supports('--length', '10px'));
}, 'CSS.supports(property, value) should parse against registered syntax');

</script>

0 comments on commit d7afcb8

Please sign in to comment.