-
Notifications
You must be signed in to change notification settings - Fork 711
[css-variables] Substitution of invalid variables into other variables #4075
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I think you're right that the current behavior / WPT aren't matched by the spec, which would treat your second rule equivalent to The following paragraph makes a custom property invalid if it uses
But, the example you gave has valid grammar, it is only invalid at computation time. Changing the spec to match implementations & tests would be the easiest course of action. So the question is, what is the cost of doing that? What use cases are prevented by the current behavior? Is it confusing for authors (e.g., when working with Houdini APIs) that custom properties behave differently from regular properties in this case? |
I think it would "only" cost us consistency. Can't think of any use-cases that would be limited (either way). Your intuition is right that this adds confusion in the Houdiniverse; there has been at least one report of confusion, though here it probably doesn't help that I've implemented registered custom properties to work per spec, which adds another de-facto inconsistency with (the actual implementation of) unregistered custom properties. Personally, I think we should at least try to change browser behavior. I'm mostly fishing for whether there's a hidden CSSWG resolution / TPAC hallway discussion / Tab Atkins tweet / hivemind consensus that custom properties should work the way they actually do in browsers, and it just never reached the spec, or whether this was just an unlucky oversight during the creation of some WPT. |
Interesting problem, thanks for reporting it. (fwiw I'm in favor of getting browsers fixed for this case if there is support for that; based on what I know I assume that wouldn't be hard and would improve consistency, especially for houdini scenarios as noted before) |
The spec does indeed say that #inner should get --y value of "foo". I'm ambivalent about which direction we fix this in, but if following the spec makes the rest of ecosystem more consistent, then we should try and fix browsers (and the tests) to follow the spec. I do like when we can keep custom properties more in line with normal properties. |
It'd be unfortunate to treat this case differently from the case where the custom properties are cyclic, where right now the spec says that they compute to the initial value rather than unset. |
Ah, good point. I made that behavior different from just being straight invalid on purpose; staying invalid rather than silently inheriting a value from higher up in the tree seemed like a better behavior for authors in the case of a cyclic reference, which is a straight-up error that needs fixing. On the other hand, more generally, I want invalid-at-computed-value-time to act as close to invalid-at-parse-time as possible, thus the "unset" behavior. So I suppose what happens to specifically custom properties that are iacvt could be argued in either direction. What should happen to registered custom properties that are iacvt? They're intended, as much as possible, to act like "real" properties; presumably then they should use the "unset" behavior, right? I also generally want unregistered properties to act like registered ones when possible, to reduce the chance of a surprising behavior change. So that suggests custom properties should stick with the specified "unset" behavior, right? I'm happy to hear arguments to the contrary on any of these points. ^_^ |
Perhaps css-variables should name the concepts invalid-at-computed-value-time and cyclic-at-computed-value-time, if we're keeping the distinction. Looks like the spec is currently saying:
IMO the same thing that happens to unregistered custom properties that are iacvt (whatever the behavior is). And registered custom properties that are cacvt should probably have the same behavior as the unregistered cacvt case.
Yes. 👍
Also yes. 👍 I think it's fine to keep the current distinction between iacvt and cacvt, if that's what we want. Although, for registered custom properties + cacvt we have to pick between consistency with standard properties ( Making both iacvt & cacvt behave as |
This makes sense to me. So the implications are:
Right? |
Right! :-) And that behavior is already defined by the spec as-is (I think). Though it might be good to be a bit more clear on the distinction between iacvt and cyclic. Related bonus information worth keeping in mind: standard properties can also participate in a cycle, but they can't be "guaranteed-invalid", so they'll have to get |
Hmmm, I forgot that they can indeed participate in cycles. Them being guaranteed-invalid wouldn't do anything anyway; you can't substitute them in, which is the only case where guaranteed-invalid does anything anyway. So okay, I'll make this clearer in the spec, and write a wpt for it (unless you already have one ready?). |
We do have WPTs for this, but they currently verify the wrong thing (hence this issue in the first place). You don't have to make a test; I'll adjust the tests we already have. :-) |
Okay, I pushed some changes defining "cyclic at computed-value time" and making "invalid at cvt" hopefully more clear. I also dfn'd "guaranteed-invalid value", the initial value of custom properties, so it can be referred to more easily (I already referred to it in the P&V spec, it's just a broken link right now until the spec processor cycles around!). |
We currently have a (WPT-enforced) bug where custom properties that reference guaranteed-invalid values [1] behave themselves as guaranteed- invalid. This is not correct per spec, which requires the custom property to behave as 'unset' in this case. This was clarified in [2], although the spec has described this behavior long before that. Unfortunately Firefox has the same issue. Safari on the other hand, does implement it correctly. [1] https://drafts.csswg.org/css-variables/#guaranteed-invalid [2] w3c/csswg-drafts#4075 Bug: 980930 Change-Id: I84a0da3aad6b72b574009d560eb868632769098a
I'm still not quite sure I agree with the behavior here being more similar to "invalid-at-parse-time", if you have multiple declarations for the same custom property, for what is worth. |
Can you elaborate on what you mean? |
We currently have a (WPT-enforced) bug where custom properties that reference guaranteed-invalid values [1] behave themselves as guaranteed- invalid. This is not correct per spec, which requires the custom property to behave as 'unset' in this case. This was clarified in [2], although the spec has described this behavior long before that. Unfortunately Firefox has the same issue. Safari on the other hand, does implement it correctly. [1] https://drafts.csswg.org/css-variables/#guaranteed-invalid [2] w3c/csswg-drafts#4075 Bug: 980930 Change-Id: I84a0da3aad6b72b574009d560eb868632769098a
We currently have a (WPT-enforced) bug where custom properties that reference guaranteed-invalid values [1] behave themselves as guaranteed- invalid. This is not correct per spec, which requires the custom property to behave as 'unset' in this case. This was clarified in [2], although the spec has described this behavior long before that. Unfortunately Firefox has the same issue. Safari on the other hand, does implement it correctly. [1] https://drafts.csswg.org/css-variables/#guaranteed-invalid [2] w3c/csswg-drafts#4075 Bug: 980930 Change-Id: I84a0da3aad6b72b574009d560eb868632769098a Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2108026 Commit-Queue: Anders Hartvoll Ruud <andruud@chromium.org> Reviewed-by: Xiaocheng Hu <xiaochengh@chromium.org> Cr-Commit-Position: refs/heads/master@{#751636}
We currently have a (WPT-enforced) bug where custom properties that reference guaranteed-invalid values [1] behave themselves as guaranteed- invalid. This is not correct per spec, which requires the custom property to behave as 'unset' in this case. This was clarified in [2], although the spec has described this behavior long before that. Unfortunately Firefox has the same issue. Safari on the other hand, does implement it correctly. [1] https://drafts.csswg.org/css-variables/#guaranteed-invalid [2] w3c/csswg-drafts#4075 Bug: 980930 Change-Id: I84a0da3aad6b72b574009d560eb868632769098a Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2108026 Commit-Queue: Anders Hartvoll Ruud <andruud@chromium.org> Reviewed-by: Xiaocheng Hu <xiaochengh@chromium.org> Cr-Commit-Position: refs/heads/master@{#751636}
We currently have a (WPT-enforced) bug where custom properties that reference guaranteed-invalid values [1] behave themselves as guaranteed- invalid. This is not correct per spec, which requires the custom property to behave as 'unset' in this case. This was clarified in [2], although the spec has described this behavior long before that. Unfortunately Firefox has the same issue. Safari on the other hand, does implement it correctly. [1] https://drafts.csswg.org/css-variables/#guaranteed-invalid [2] w3c/csswg-drafts#4075 Bug: 980930 Change-Id: I84a0da3aad6b72b574009d560eb868632769098a Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2108026 Commit-Queue: Anders Hartvoll Ruud <andruud@chromium.org> Reviewed-by: Xiaocheng Hu <xiaochengh@chromium.org> Cr-Commit-Position: refs/heads/master@{#751636}
I mean that if you have:
I'm not sure my expectation would be that |
…d var() should behave as 'unset', a=testonly Automatic update from web-platform-tests [css-variables] Custom props with invalid var() should behave as 'unset' We currently have a (WPT-enforced) bug where custom properties that reference guaranteed-invalid values [1] behave themselves as guaranteed- invalid. This is not correct per spec, which requires the custom property to behave as 'unset' in this case. This was clarified in [2], although the spec has described this behavior long before that. Unfortunately Firefox has the same issue. Safari on the other hand, does implement it correctly. [1] https://drafts.csswg.org/css-variables/#guaranteed-invalid [2] w3c/csswg-drafts#4075 Bug: 980930 Change-Id: I84a0da3aad6b72b574009d560eb868632769098a Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2108026 Commit-Queue: Anders Hartvoll Ruud <andruud@chromium.org> Reviewed-by: Xiaocheng Hu <xiaochengh@chromium.org> Cr-Commit-Position: refs/heads/master@{#751636} -- wpt-commits: fc793094912b67b45a94d101819bffb9b9307710 wpt-pr: 22318
…d var() should behave as 'unset', a=testonly Automatic update from web-platform-tests [css-variables] Custom props with invalid var() should behave as 'unset' We currently have a (WPT-enforced) bug where custom properties that reference guaranteed-invalid values [1] behave themselves as guaranteed- invalid. This is not correct per spec, which requires the custom property to behave as 'unset' in this case. This was clarified in [2], although the spec has described this behavior long before that. Unfortunately Firefox has the same issue. Safari on the other hand, does implement it correctly. [1] https://drafts.csswg.org/css-variables/#guaranteed-invalid [2] w3c/csswg-drafts#4075 Bug: 980930 Change-Id: I84a0da3aad6b72b574009d560eb868632769098a Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2108026 Commit-Queue: Anders Hartvoll Ruud <andruud@chromium.org> Reviewed-by: Xiaocheng Hu <xiaochengh@chromium.org> Cr-Commit-Position: refs/heads/master@{#751636} -- wpt-commits: fc793094912b67b45a94d101819bffb9b9307710 wpt-pr: 22318
…d var() should behave as 'unset', a=testonly Automatic update from web-platform-tests [css-variables] Custom props with invalid var() should behave as 'unset' We currently have a (WPT-enforced) bug where custom properties that reference guaranteed-invalid values [1] behave themselves as guaranteed- invalid. This is not correct per spec, which requires the custom property to behave as 'unset' in this case. This was clarified in [2], although the spec has described this behavior long before that. Unfortunately Firefox has the same issue. Safari on the other hand, does implement it correctly. [1] https://drafts.csswg.org/css-variables/#guaranteed-invalid [2] w3c/csswg-drafts#4075 Bug: 980930 Change-Id: I84a0da3aad6b72b574009d560eb868632769098a Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2108026 Commit-Queue: Anders Hartvoll Ruud <andruudchromium.org> Reviewed-by: Xiaocheng Hu <xiaochenghchromium.org> Cr-Commit-Position: refs/heads/master{#751636} -- wpt-commits: fc793094912b67b45a94d101819bffb9b9307710 wpt-pr: 22318 UltraBlame original commit: aaae9e1c209687addde4400f03ab390667307b15
…d var() should behave as 'unset', a=testonly Automatic update from web-platform-tests [css-variables] Custom props with invalid var() should behave as 'unset' We currently have a (WPT-enforced) bug where custom properties that reference guaranteed-invalid values [1] behave themselves as guaranteed- invalid. This is not correct per spec, which requires the custom property to behave as 'unset' in this case. This was clarified in [2], although the spec has described this behavior long before that. Unfortunately Firefox has the same issue. Safari on the other hand, does implement it correctly. [1] https://drafts.csswg.org/css-variables/#guaranteed-invalid [2] w3c/csswg-drafts#4075 Bug: 980930 Change-Id: I84a0da3aad6b72b574009d560eb868632769098a Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2108026 Commit-Queue: Anders Hartvoll Ruud <andruudchromium.org> Reviewed-by: Xiaocheng Hu <xiaochenghchromium.org> Cr-Commit-Position: refs/heads/master{#751636} -- wpt-commits: fc793094912b67b45a94d101819bffb9b9307710 wpt-pr: 22318 UltraBlame original commit: aaae9e1c209687addde4400f03ab390667307b15
…d var() should behave as 'unset', a=testonly Automatic update from web-platform-tests [css-variables] Custom props with invalid var() should behave as 'unset' We currently have a (WPT-enforced) bug where custom properties that reference guaranteed-invalid values [1] behave themselves as guaranteed- invalid. This is not correct per spec, which requires the custom property to behave as 'unset' in this case. This was clarified in [2], although the spec has described this behavior long before that. Unfortunately Firefox has the same issue. Safari on the other hand, does implement it correctly. [1] https://drafts.csswg.org/css-variables/#guaranteed-invalid [2] w3c/csswg-drafts#4075 Bug: 980930 Change-Id: I84a0da3aad6b72b574009d560eb868632769098a Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2108026 Commit-Queue: Anders Hartvoll Ruud <andruudchromium.org> Reviewed-by: Xiaocheng Hu <xiaochenghchromium.org> Cr-Commit-Position: refs/heads/master{#751636} -- wpt-commits: fc793094912b67b45a94d101819bffb9b9307710 wpt-pr: 22318 UltraBlame original commit: aaae9e1c209687addde4400f03ab390667307b15
…ld be unset, not invalid. r=heycam See w3c/csswg-drafts#4075. There are tests that will get updated and this will make pass in bug 1623347. Differential Revision: https://phabricator.services.mozilla.com/D67373
…ld be unset, not invalid. r=heycam See w3c/csswg-drafts#4075. There are tests that will get updated and this will make pass in bug 1623347. Differential Revision: https://phabricator.services.mozilla.com/D67373 --HG-- extra : moz-landing-system : lando
Yeah, there's limits on how close we can get, definitely. Thus "as close as possible". The general principle is to make registered custom properties act more like built-in properties when possible, and make unregistered act like registered when possible, to reduce the overall cognitive load. Built-ins can grammar-check at parse-time and get richer error recovery (falling back to the previous value in the cascade), which custom properties aren't capable of. But if you force a built-in property to delay grammar checking until computed-value time (by using a And yeah, I do think that cyclic properties becoming the guaranteed-invalid value to help in realizing errors is a better behavior, despite it technically being a behavior difference from built-ins. Built-ins can only go cyclic amongst themselves in rare cases ('em' in font-size, %s in sizing properties sometimes, etc), and handle it in bespoke ways, so there's no consistent behavior to start from, and adding another bespoke error behavior isn't making the situation any worse than it already is. ^_^ |
…ld be unset, not invalid. r=heycam See w3c/csswg-drafts#4075. There are tests that will get updated and this will make pass in bug 1623347. Differential Revision: https://phabricator.services.mozilla.com/D67373 UltraBlame original commit: d49bad3acbc6c4a8eb3227b24f6bf18ae06c072e
…ld be unset, not invalid. r=heycam See w3c/csswg-drafts#4075. There are tests that will get updated and this will make pass in bug 1623347. Differential Revision: https://phabricator.services.mozilla.com/D67373 UltraBlame original commit: d49bad3acbc6c4a8eb3227b24f6bf18ae06c072e
…ld be unset, not invalid. r=heycam See w3c/csswg-drafts#4075. There are tests that will get updated and this will make pass in bug 1623347. Differential Revision: https://phabricator.services.mozilla.com/D67373 UltraBlame original commit: d49bad3acbc6c4a8eb3227b24f6bf18ae06c072e
…nset, not invalid. See w3c/csswg-drafts#4075. There are tests that will get updated and this will make pass in bug 1623347. Differential Revision: https://phabricator.services.mozilla.com/D67373
…nset, not invalid. See w3c/csswg-drafts#4075. There are tests that will get updated and this will make pass in bug 1623347. Differential Revision: https://phabricator.services.mozilla.com/D67373
https://bugs.chromium.org/p/chromium/issues/detail?id=1110188 This decision seems like it was heavily considered in both directions since it's contradictory in one interpretation. I would really really really appreciate a re-evaluation of where it landed though because the consequences have entirely removed the ability to have a --css-variable component be nested with itself and use fallback behavior in And just as @emilio presented, #4075 (comment) this behavior looks unexpected even on the surface Further, the spec specifically says that the cascade value should be thrown out by the time it's become invalid at computed-value time:
Also, This change has made the "guaranteed invalid" behavior of css variables into an edge case only guaranteed on :root |
Hm, looking at your referenced test case in the bug, it seems like a somewhat unrelated issue to this thread. What you're seeing is just the fact that a property becoming iacvt makes it
Emilio's comment doesn't look relevant here, either - he's saying that in his example, the variables behavior doesn't act like "drop invalid properties" (since we can't actually do parse-time dropping). But in your example, it does look exactly like dropping an invalid property - if you pretend the child's It sounds like what you're wanting is for the guaranteed-invalid value to be preserved as it's substituted thru custom properties, so that the iacvt behavior of making the value This isn't an unreasonable request! In w3c/css-houdini-drafts#994 (comment) Amelia asks for the ability to explicitly allow a registered property to still assume the guaranteed-invalid value, which is currently only possible when you have a completely unrestricted grammar. Implicitly, this is recognizing that the guaranteed-invalid value actually is "valid" in some circumstances; it's guaranteed to never match the grammar of any predefined CSS property, but it's part of the value space (and thus, matches the grammar) of unregistered custom properties, or registered ones with unrestricted grammar. This is a different choice than what we've currently made in the spec, but it's not a wrong one. And I think I've talked myself into preferring it. It would be a minor behavior change, tho. @andruud, any thoughts? |
Actually, I'm taking this over to #5370; reclosing this issue. |
…d var() should behave as 'unset', a=testonly Automatic update from web-platform-tests [css-variables] Custom props with invalid var() should behave as 'unset' We currently have a (WPT-enforced) bug where custom properties that reference guaranteed-invalid values [1] behave themselves as guaranteed- invalid. This is not correct per spec, which requires the custom property to behave as 'unset' in this case. This was clarified in [2], although the spec has described this behavior long before that. Unfortunately Firefox has the same issue. Safari on the other hand, does implement it correctly. [1] https://drafts.csswg.org/css-variables/#guaranteed-invalid [2] w3c/csswg-drafts#4075 Bug: 980930 Change-Id: I84a0da3aad6b72b574009d560eb868632769098a Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2108026 Commit-Queue: Anders Hartvoll Ruud <andruud@chromium.org> Reviewed-by: Xiaocheng Hu <xiaochengh@chromium.org> Cr-Commit-Position: refs/heads/master@{#751636} -- wpt-commits: fc793094912b67b45a94d101819bffb9b9307710 wpt-pr: 22318
…ld be unset, not invalid. r=heycam See w3c/csswg-drafts#4075. There are tests that will get updated and this will make pass in bug 1623347. Differential Revision: https://phabricator.services.mozilla.com/D67373
I have found nothing in the spec that says the above does not apply to custom property declarations themselves. If I'm not mistaken, this means that the following:
... will for
#inner
produce a computed valuefoo
for--y
. This is because--y
is an inherited property, and per the spec text above the value is treated asunset
.Chrome and FF currently treat
--y
as the 'invalid at computed-value time'-value, and we have WPT that verify this seemingly incompliant behavior.Is my interpretation of the spec correct? If yes, do we change the spec or fix WPT?
The text was updated successfully, but these errors were encountered: