Skip to content

Commit fbf5cb8

Browse files
andruudchromium-wpt-export-bot
authored andcommitted
[functions] Validate defaults against their type
The spec was recently clarified to make @function rules with "mistyped" defaults invalid. For example, the following is now invalid, because the default given for --arg doesn't match the type given for --arg: @function --foo(--arg <color>: 10px) { /* ... */ } w3c/csswg-drafts#12243 Fixed: 423673310 Change-Id: I3239b573ece22bb48746a496758d53f57ac00b70 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6632858 Commit-Queue: Anders Hartvoll Ruud <[email protected]> Reviewed-by: Steinar H Gunderson <[email protected]> Cr-Commit-Position: refs/heads/main@{#1472448}
1 parent d742622 commit fbf5cb8

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

css/css-mixins/at-function-parsing.html

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060

6161
// Defaults.
6262
test_valid_prelude('@function --foo(--x : 10px)');
63+
test_valid_prelude('@function --foo(--x type(*): 10px)');
6364
test_valid_prelude('@function --foo(--x <length>: 10px)');
6465
test_valid_prelude('@function --foo(--x <length>: 10px, --y)');
6566
test_valid_prelude('@function --foo(--x, --y <length>: 10px)');
@@ -69,11 +70,16 @@
6970
// a default, even though there's no way to actually call --foo()
7071
// with just --y:
7172
test_valid_prelude('@function --foo(--x:1px, --y, --z:2px)');
72-
// The value does not have to match the type during @function parsing:
73-
test_valid_prelude('@function --foo(--x <angle>: 10px)');
7473

7574
test_invalid_prelude('@function --foo(--x: 10px !important)');
7675

76+
// Default type mismatch.
77+
test_invalid_prelude('@function --foo(--x <length>: 10deg)');
78+
test_invalid_prelude('@function --foo(--x <angle>: 10px)');
79+
test_invalid_prelude('@function --foo(--x <color>: 10px)');
80+
test_invalid_prelude('@function --foo(--x type(<color>+): red 5)');
81+
test_invalid_prelude('@function --foo(--x type(auto | none): thing)');
82+
7783
// Lists.
7884
test_valid_prelude('@function --foo(--x <length>#)');
7985
test_valid_prelude('@function --foo(--x <length>+)');

0 commit comments

Comments
 (0)