-
Notifications
You must be signed in to change notification settings - Fork 716
[css-values-5] attr()'s "px"/etc keywords #11034
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'm a bit ambivalent about it. I can see the theoretical purity of it, but realistically we're not going to use the full grammar syntax here, only a single |
It's actually fine to use the whole grammar here, now that attr() is an arbitrary-substitution function (aka var()-like). We don't need to know its type at parse time, so it's perfectly fine to write And the spec already allows So I think we either need to drop the "specific unit" functionality, as suggested, or make the syntax part more distinguishable from other syntax. Or, I guess, add some branches to the |
Even if at some point we want to allow |
To a little clearer, since @fantasai was confused in some personal conversation: Right now, per spec, you can say That's the ambiguity with I still think we can probably just drop that functionality entirely in favor of using calc(), but if we did want to preserve it, I think we'd do it with some special syntax on the number production, like |
I think this will be a popular thing to do, and
|
We absolutely need simpler syntax.
|
Will |
Anything of that sort is possible, sure, but we should assume that anything we allow in this production might eventually show up in a CSS spec, or possibly collide with something in a CSS spec. Having an unbounded set of And, personally, I think it communicates better. If I saw |
Yeah, I agree with that.
OK, I'll buy that too. Ready for Agenda+? |
Yup, Agenda+ to approve the Despite my earlier preference to just push this functionality out entirely, I think this is the right way to go, since you can accept multiple types with |
Ah, an additional point from some internal conversation - the |
With recent modifications in attr() spec [0], <attr-type> is now replaced with <syntax> [1], so replaced css_attr_type with css syntax stream parser. Since <dimension-unit> is not part of <syntax>, temporary remove tests with dimension unit types until the spec issue [2] will be resolved. [0] https://drafts.csswg.org/css-values-5/#attr-notation> [1] https://drafts.csswg.org/css-values-5/#css-syntax [2] w3c/csswg-drafts#11034 Bug: 369858674, 40320391 Change-Id: I865c8cf5c848339a9766be0a04c5dc3f94983878
With recent modifications in attr() spec [0], <attr-type> is now replaced with <syntax> [1], so replaced css_attr_type with css syntax stream parser. Since <dimension-unit> is not part of <syntax>, temporary remove tests with dimension unit types until the spec issue [2] will be resolved. [0] https://drafts.csswg.org/css-values-5/#attr-notation> [1] https://drafts.csswg.org/css-values-5/#css-syntax [2] w3c/csswg-drafts#11034 Bug: 369858674, 40320391 Change-Id: I865c8cf5c848339a9766be0a04c5dc3f94983878 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5975668 Reviewed-by: Anders Hartvoll Ruud <[email protected]> Commit-Queue: Munira Tursunova <[email protected]> Cr-Commit-Position: refs/heads/main@{#1376296}
With recent modifications in attr() spec [0], <attr-type> is now replaced with <syntax> [1], so replaced css_attr_type with css syntax stream parser. Since <dimension-unit> is not part of <syntax>, temporary remove tests with dimension unit types until the spec issue [2] will be resolved. [0] https://drafts.csswg.org/css-values-5/#attr-notation> [1] https://drafts.csswg.org/css-values-5/#css-syntax [2] w3c/csswg-drafts#11034 Bug: 369858674, 40320391 Change-Id: I865c8cf5c848339a9766be0a04c5dc3f94983878 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5975668 Reviewed-by: Anders Hartvoll Ruud <[email protected]> Commit-Queue: Munira Tursunova <[email protected]> Cr-Commit-Position: refs/heads/main@{#1376296}
With recent modifications in attr() spec [0], <attr-type> is now replaced with <syntax> [1], so replaced css_attr_type with css syntax stream parser. Since <dimension-unit> is not part of <syntax>, temporary remove tests with dimension unit types until the spec issue [2] will be resolved. [0] https://drafts.csswg.org/css-values-5/#attr-notation> [1] https://drafts.csswg.org/css-values-5/#css-syntax [2] w3c/csswg-drafts#11034 Bug: 369858674, 40320391 Change-Id: I865c8cf5c848339a9766be0a04c5dc3f94983878 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5975668 Reviewed-by: Anders Hartvoll Ruud <[email protected]> Commit-Queue: Munira Tursunova <[email protected]> Cr-Commit-Position: refs/heads/main@{#1376296}
To re-iterate and elaborate on my comment in the
|
I think that's fine. CSS is always grammatically flexible, and those examples of future growth looks just fine to me. If and when we add enough specifiers for it to start getting confusing, we can worry about named arguments; until then, we can add them ad-hoc because it's shorter and easier. |
…a=testonly Automatic update from web-platform-tests Use css syntax stream parser in attr() With recent modifications in attr() spec [0], <attr-type> is now replaced with <syntax> [1], so replaced css_attr_type with css syntax stream parser. Since <dimension-unit> is not part of <syntax>, temporary remove tests with dimension unit types until the spec issue [2] will be resolved. [0] https://drafts.csswg.org/css-values-5/#attr-notation> [1] https://drafts.csswg.org/css-values-5/#css-syntax [2] w3c/csswg-drafts#11034 Bug: 369858674, 40320391 Change-Id: I865c8cf5c848339a9766be0a04c5dc3f94983878 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5975668 Reviewed-by: Anders Hartvoll Ruud <[email protected]> Commit-Queue: Munira Tursunova <[email protected]> Cr-Commit-Position: refs/heads/main@{#1376296} -- wpt-commits: e0217e09fb4256ee8a6f80b0b70d07a0db249d6f wpt-pr: 48909
…a=testonly Automatic update from web-platform-tests Use css syntax stream parser in attr() With recent modifications in attr() spec [0], <attr-type> is now replaced with <syntax> [1], so replaced css_attr_type with css syntax stream parser. Since <dimension-unit> is not part of <syntax>, temporary remove tests with dimension unit types until the spec issue [2] will be resolved. [0] https://drafts.csswg.org/css-values-5/#attr-notation> [1] https://drafts.csswg.org/css-values-5/#css-syntax [2] w3c/csswg-drafts#11034 Bug: 369858674, 40320391 Change-Id: I865c8cf5c848339a9766be0a04c5dc3f94983878 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5975668 Reviewed-by: Anders Hartvoll Ruud <[email protected]> Commit-Queue: Munira Tursunova <[email protected]> Cr-Commit-Position: refs/heads/main@{#1376296} -- wpt-commits: e0217e09fb4256ee8a6f80b0b70d07a0db249d6f wpt-pr: 48909
…a=testonly Automatic update from web-platform-tests Use css syntax stream parser in attr() With recent modifications in attr() spec [0], <attr-type> is now replaced with <syntax> [1], so replaced css_attr_type with css syntax stream parser. Since <dimension-unit> is not part of <syntax>, temporary remove tests with dimension unit types until the spec issue [2] will be resolved. [0] https://drafts.csswg.org/css-values-5/#attr-notation> [1] https://drafts.csswg.org/css-values-5/#css-syntax [2] w3c/csswg-drafts#11034 Bug: 369858674, 40320391 Change-Id: I865c8cf5c848339a9766be0a04c5dc3f94983878 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5975668 Reviewed-by: Anders Hartvoll Ruud <[email protected]> Commit-Queue: Munira Tursunova <[email protected]> Cr-Commit-Position: refs/heads/main@{#1376296} -- wpt-commits: e0217e09fb4256ee8a6f80b0b70d07a0db249d6f wpt-pr: 48909
We're now resolved on not doing |
Resolution: #11035 (comment) |
In #10437 (comment) we resolved to change
attr()
's type argument from a bespoke list of keywords to the newly-minted "CSS grammar in CSS" syntax.Most of the existing attr() type keywords translate over just fine (usually just wrapping them in
<>
characters), but the unit names don't. That is, under the current spec you can writewidth: attr(foo px)
, and given an element like<div foo=500>
, it'll be parsed as a number and then be assumed to be apx
value. There's no way to express this sort of behavior in CSS grammar, tho.Note that this is basically just a convenience; one could instead write
calc(1px * attr(foo <number>))
and get the same result. So the use-case is covered no matter what.Do we want to try and allow this, tho? The issue is that bare keywords already have meaning in the
<css-syntax>
production (they represent those keywords, same as in any other CSS grammar), so it would be somewhat awkward to mix them in.I propose that we just drop that functionality, and let
calc()
cover the issue of "interpret a number as a particular unit".The text was updated successfully, but these errors were encountered: