W3C home > Mailing lists > Public > www-style@w3.org > April 2012

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

From: Kang-Hao (Kenny) Lu <kennyluck@csail.mit.edu>
Date: Thu, 05 Apr 2012 08:59:35 +0800
Message-ID: <4F7CEE77.5060101@csail.mit.edu>
To: "Tab Atkins Jr." <jackalmage@gmail.com>
CC: www-style list <www-style@w3.org>
(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.

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

This archive was generated by hypermail 2.4.0 : Friday, 25 March 2022 10:08:14 UTC