Re: [css-variables] ...let's change the syntax

+1 to every single remark expressed in Chris's reply.

> _property is a common CSS hack targeting IE6. So those in-the-wild 
> stylesheets would suddenly start being interpreted as variables by modern 
> browsers.
>
> Maybe not a big deal but... aesthetically, I find underscores in CSS files 
> displeasing.
>
> An issue we're bumping into in the sass community now is namespace 
> collisions from 3rd-party libraries. It would be nice if CSS could avoid 
> our mistake by forcing a namespace for custom properties.
>
> Is there any reason we can't use dot notation for this?
>
> div {
>   my.color: red;
>   bootstrap.color: blue;
>   color: my.color;
>   background-color: bootstrap.color;
> }
>
> And yes, I think we should have right hand side symmetry with the 
> declaration.



Now, this is a more important change than what Tab is actually proposing, 
aka one of nature to potentially delay the final Firefox implementation.

That being said, Custom Properties are only useful once all browsers support 
them (or at least a majority of them that's sufficiently broad the justify 
the use of a polyfill for the others), so I'm not enclined to consider this 
a huge deal. I prefer we trade a bit of time for a better design than the 
opposite.



To add some new elements to the discussion, the case of default values can 
still be handled without a "var(*,*)" function using a "||" operator, as I 
proposed before, whose semantics would match the JavaScript one : (undefined 
|| defined-value) == (defined-value) where any expression whose any member 
is undefined becomes undefined. Example:

{
    some.bad-length: 5 px;
    some.bad-number: three;
    width: calc(2 * some.bad-length || 100%); //100%;
    height: calc(some.bad-number * 25% || auto); //auto;
    padding: calc(undefined.property || 0); //0;
    margin: calc(undefined.property || undefined.property || 0); //0;
}

If we are going that road, I think we should reserve a few 'namespaces' for 
future usage (like 'css.*' and 'style.*'), though. 

Received on Thursday, 13 March 2014 17:20:51 UTC