-
Notifications
You must be signed in to change notification settings - Fork 715
[css-variables] Add User Agent properties and constant() #1817
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
Conversation
@tabatkins I expect you'll have a lot of comments on this. For one, do you want to use the term global variables? Also, if you want to allow the user to set their own --global-property, then I'd appreciate help on how that should be done. I assume it should only be allowed in one place, e.g :root? |
The title of the commit should be User Agent properties, not variables. |
How about just using "Constants" as the name everywhere, instead of "User Agent Properties" but then the syntax is This would also imply changing |
|
3a) Alternately, make the JS API hang off of individual stylesheets, and have it be just a shorthand for adding/removing/mutating the rules directly. Then precedence is automatic - you're just adding a rule to a given stylesheet, and the standard "later stylesheets win" rule comes into effect. This is less convenient for authors, tho - you need to figure out which stylesheet a given constant is coming from if you want to manipulate it. |
How would this work for UA predefined constants? Would they be expected to have an @global rule in a stylesheet at UA precedence level, which gets updated if the value changes? I'm asking because from our perspective, UA predefined constants are the main kind we care about, and author-defined constants are at most a tangential side benefit. Also, I really think this concept should have a single name in syntax. Either |
There is. Couldn't global variables / constants change after page open? e.g. in case of iPhone X, what would happen if user rotates the phone or split the screen? If we substitute them during parsing, we would never be able to change it dynamically. |
It would require a reparse, yes.
The UA stylesheet is unobservable, so this doesn't matter. The only observable part would be the JS API, which would I suppose have readonly entries in the map that could be listened to for changes.
Oh, yes, certainly. All the discussion of "global variables" just led my fingers to type |
Is the map global rather than per-stylesheet? How are read-only entires represented? |
Depends on how we answer my (3)! Global is easier for authors, I think, but per-stylesheet has simpler semantics. One reasonable answer is both: we have a global map hanging off of the That way the actual
The map-like just throws on attempted sets/deletes/clears for those keys. |
Parsing is slow, and loses information, e.g. how would you reparse a declaration inserted via CSSOM? I don't think reparse is an option here... |
Yeah, the more I think about this, the more I think we should just hew close to standard var() semantics. That makes it more amenable to having multi-values too. |
Went ahead and wrote up the feature as a separate spec instead: https://drafts.csswg.org/css-env-1/ More details back in #1693 |
Addresses issue #1693