Re: [css-variables] Should var properties respect !important?

(12/04/03 9:31), Tab Atkins Jr. wrote:
> While implementing the parsing side of Variables recently, Luke
> realized that it's unclear whether an !important token at the end of a
> variable's value actually makes it important, or if it's just treated
> as part of the variable's value.  I'm not sure which option is the
> best, but here are some arguments for both.

Given that at the moment the spec refers to the core grammar instead of
Appendix G and the fact that '!important' consists of two tokens in the
core grammar. You probably need to consider one more example:

:root {
  var-importance: ! ;
  counter-increment: x var(importance) important;
}



In any case, I think all options in 1) are too strange. 3), 2b) and 2c)
are acceptable but they also not very natural, so I pefer 2a) or
Florian's variant. I think I like 2a) better and we should also make the
above invalid at parse time, which seems to be more performant.

> 2a) If a non-trailing !important appears in a var property, it's a syntax error.
> 
> This prevents us from getting into the (2b) and (2c) situations
> entirely, but it means more preprocessing of variables.  Every
> restriction we place on a variable's value reduces its utility as a
> generic cascade-using information carrier, which I consider an
> important use-case (that is, using var properties to attach data to
> the DOM for JS purposes, rather than using them in the var()
> function).

There are already random restrictions from the value production
(Dangling ';' '{' '}' '(' ')' '[' ']' are not allowed), and I see no
particular harm in adding '!' to this list). For the information carrier
use case, I think we should advise authors to quote data outside the
{nmchar} range.


Cheers,
Kenny

Received on Thursday, 5 April 2012 01:00:03 UTC