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

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

From: Glenn Adams <glenn@skynav.com>
Date: Sat, 1 Sep 2012 08:27:50 +0800
Message-ID: <CACQ=j+dvML4hnhPe-TdKAO8LaDfvXaZ0yDRA4-OEx63Ax-LgcQ@mail.gmail.com>
To: "Tab Atkins Jr." <jackalmage@gmail.com>
Cc: www-style list <www-style@w3.org>
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'] = ...
Received on Saturday, 1 September 2012 00:28:40 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 17:20:59 GMT