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:37:58 +0800
Message-ID: <CACQ=j+f5Fy1kcQnZHsgSQqGA8w3m5DokS-x3vSVF=dS4kBv42Q@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:29 AM, Tab Atkins Jr. <jackalmage@gmail.com> wrote:

> 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".
>

Understood. I'd like to hear what others think on this. I prefer spelled
out IDL attribute names, as currently employed, rather than abbreviations
intended to be a form of syntactic sugar.
Received on Saturday, 1 September 2012 00:38:45 GMT

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