- From: Tab Atkins Jr. <jackalmage@gmail.com>
- Date: Mon, 2 Apr 2012 18:31:47 -0700
- To: www-style list <www-style@w3.org>
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. 1) Treat !important as part of the variable's value This option reduces the amount of interpretation on the var property's value, which is currently *almost* entirely uninterpreted (only var() references are expanded within it). Within (1), there are three sub-options: 1a) If variable expansion places an !important at the end of a property value, pay attention to it This makes sense because it's consistent with "expand variables then parse like normal", but I don't think it's workable. Expansion doesn't occur until computed-value time, long after the cascade is run, and !important affects the cascade. Thus, this appears to be a major violation of the value computation layering. 1b) If variable expansion produces an !important at the end of a property value, ignore it. (!important appearing anywhere else is a syntax error, like usual) This is the minimal change - you expand variables, parse like normal, and then simply ignore a trailing !important because it's too late to act on. 1c) If variable expansion produces an !important token anywhere, ignore it. This is somewhat inconsistent with "expand variables then parse like normal", but it has the benefit of being stable across small edits - adding something to a property such that the "!important"-carrying var is no longer the last component won't cause a sudden mysterious syntax error. 2) Treat !important like normal, and have it effect the cascade (and not be part of the variable's value) The benefit of this is that you have the normal !important behavior, which may be less surprising. Though using !important is *usually* a bad idea, on occasion it's worthwhile, and this preserves that ability for those cases. This also has sub-options: 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). 2b) and 2c) Non-trailing !important in the var property isn't a syntax error; it's treated like (1b) or (1c) when expanded Like I said, I'm not strongly in favor of any option. Thoughts? ~TJ
Received on Tuesday, 3 April 2012 01:32:35 UTC