Re: [css-variables] How to spec the OM for vars?

On Fri, Aug 31, 2012 at 5:27 PM, Glenn Adams <glenn@skynav.com> wrote:
> On Sat, Sep 1, 2012 at 8:12 AM, Tab Atkins Jr. <jackalmage@gmail.com> wrote:
>> Based on the feedback in this thread, I've now specced the API:
>> <http://dev.w3.org/csswg/css-variables/#cssom>
>>
>> I've gone with adding a "var" attribute to CSSStyleDeclaration, which
>> is a CSSVariablesDeclaration object.
>>
>> The CSSVariablesDeclaration interface just contains a
>> getter/setter/creator/deleter.  It accepts property names *without*
>> the "var-" prefix, like so:
>>
>> el.style.var.foo /* equal to el.style.getPropertyValue('var-foo') */
>>
>> I decided not to do any camelCase to dashes conversion, because it
>> wouldn't work if any component of the var name didn't start with an
>> ASCII lowercase letter. The shorthand .form only works if your var
>> name was a single JS ident, according to normal JS rules.  If your var
>> name doesn't match that, just use the array syntax:
>>
>> el.style.var['foo-bar'] /* equal to
>> el.style.getPropertyValue('var-foo-bar') */
>>
>> Is this acceptable?  If so, we need to re-resolve to publish a WD, as
>> this is a major change.
>
>
> I'm not keen on an abbreviated 'var' instead of 'variables', particularly
> since it also happens to be a JS/ES keyword.
>
> If you wish to shorten typing, just use
>
> var v = el.style.variables;
> v['foo-bar'] = ...

I chose "var" specifically as a shout-out to the syntax for custom
property names.  "el.style.var.foo" looks like "var-foo".

~TJ

Received on Saturday, 1 September 2012 00:30:00 UTC