commit 32d9faafe2d212b2a32cd4206d3f813244851be9
parent 0b4b72b16fe3ba389075aa31aea573fdd72666d4
Author: Steinar H. Gunderson <sesse@chromium.org>
Date: Mon, 27 Oct 2025 10:08:18 +0000
Bug 1996325 [wpt PR 55643] - Rework mixin @apply argument parsing., a=testonly
Automatic update from web-platform-tests
Rework mixin @apply argument parsing.
We used to call ConsumeFunctionArguments(), which assumes that we've
already done syntax verification before and can be lax. Instead, make
what's essentially a clone of ConsumeCustomFunction() (which is the
code path that actually does verification during the initial parse of
unparsed declaration values), and make it return CSSVariableData for
each argument. This also reduces the amount of re-parsing we need to
do when actually applying argument values coming from mixins.
Add basic tests for actually rejecting invalid parameters.
Bug: 406935599
Change-Id: I04ea90dec8c5fc3ded8cf160edcbc90014d35612
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7083008
Commit-Queue: Steinar H Gunderson <sesse@chromium.org>
Reviewed-by: Anders Hartvoll Ruud <andruud@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1535122}
--
wpt-commits: b0d763c44140477d920aeb193e6446f66a925423
wpt-pr: 55643
Diffstat:
1 file changed, 34 insertions(+), 0 deletions(-)
diff --git a/testing/web-platform/tests/css/css-mixins/mixin-parameters.tentative.html b/testing/web-platform/tests/css/css-mixins/mixin-parameters.tentative.html
@@ -394,5 +394,39 @@
assert_equals(getComputedStyle(target).getPropertyValue('--some-length'), '12px');
}, 'var() typed default parameters are resolved against the element');
</script>
+
+ <style>
+ @mixin --m16(--arg: !!) { /* Invalid declaration. */
+ color: red;
+ }
+ #e16 {
+ color: green;
+ @apply --m16();
+ }
+ </style>
+ <div><div id="e16">This text should be green.</div></div>
+ <script>
+ test(() => {
+ let target = document.getElementById('e16');
+ assert_equals(getComputedStyle(target).color, 'rgb(0, 128, 0)');
+ }, 'Invalid defaults should skip declaration, even on unused arguments');
+ </script>
+
+ <style>
+ @mixin --m17(--arg) {
+ color: red;
+ }
+ #e17 {
+ color: green;
+ @apply --m17(!!!); /* Invalid invocation. */
+ }
+ </style>
+ <div><div id="e17">This text should be green.</div></div>
+ <script>
+ test(() => {
+ let target = document.getElementById('e17');
+ assert_equals(getComputedStyle(target).color, 'rgb(0, 128, 0)');
+ }, 'Invalid @apply arguments should skip declaration');
+ </script>
</body>
</html>