|
|
|
|
|
by jdmichal
4572 days ago
|
|
There is no singular value for a variable. (Otherwise they would be constants, not variables.) Here's an example: :root, .green.applyColor {
var-color: #00FF00;
}
.red.applyColor {
var-color: #FF0000;
}
.blue.applyColor {
var-color: #0000FF;
}
.applyColor {
color: var(color);
}
With this style sheet, items with the "applyColor" class will default to green, unless they also have the class "blue" or "red", in which case the color will switch appropriately.So how, exactly, is a CSS processor supposed to read this definition once and come up with a single internal constant for the variable "color" that can be looked up in constant time? And how does that offer any advantage over just using its already-programmed cascading rules to properly resolve "var-color" whenever it encounters "var(color)"? |
|