W3C home > Mailing lists > Public > www-style@w3.org > February 2014

Re: [css-variables] do we need to have the CSSVariableMap at all?

From: Tab Atkins Jr. <jackalmage@gmail.com>
Date: Thu, 6 Feb 2014 15:57:24 -0800
Message-ID: <CAAWBYDDwivODF8H6MqiYAYUDhcu697iAaas0S-WGy3UXVxrUaA@mail.gmail.com>
To: Cameron McCormack <cam@mcc.id.au>
Cc: www-style list <www-style@w3.org>
On Thu, Feb 6, 2014 at 2:42 PM, Cameron McCormack <cam@mcc.id.au> wrote:
> Hi,
>
> I'm wondering whether we need to have the CSSVariableMap at all.  What does
> it make easier that you can't do by interacting with the declaration object
> itself?  To look up and set individual variables, you can do
> decl.setProperty("var-x", "something") and decl.getPropertyValue("var-x").
>
> The CSSVariableMap would make it easier to get an iterator for the
> variables, but I'm struggling to see when you'd want to do that.

When you're using "var-" as an author prefix for piping around custom
CSS properties, rather than using custom properties as variables, the
ability to iterate the variables on an element is invaluable.

(There are other possible ways to expose this, which are perhaps even
better - maybe expose a way to query the document for all elements
with a particular custom property set on them? I'm open to
reconsidering this.)

Plus, being able to say "el.style.var.foo" is just way more convenient
than "el.style.getPropertyValue('var-foo')".  It's weird that you have
to resort to the annoying explicit methods for variables, just because
they're not camel-caseable like the other properties.

~TJ
Received on Thursday, 6 February 2014 23:58:12 UTC

This archive was generated by hypermail 2.3.1 : Monday, 2 May 2016 14:39:18 UTC