W3C home > Mailing lists > Public > www-style@w3.org > November 2011

Re: [css-variables] Extending the CSSStyleDeclaration interface in IDL

From: Cameron McCormack <cam@mcc.id.au>
Date: Tue, 15 Nov 2011 09:33:52 +1300
Message-ID: <4EC17B30.4030105@mcc.id.au>
To: "Tab Atkins Jr." <jackalmage@gmail.com>
CC: www-style list <www-style@w3.org>
On 11/11/11 11:48 AM, Tab Atkins Jr. wrote:
> I just logged an issue on the Variables spec about the necessary
> extensions to the CSSStyleDeclaration interface (the object that's
> returned from el.style and getComputedStyle(el) ).  I'd appreciate
> some help in figuring out how to express what I want in WebIDL.
>
> The set of data properties is unbounded, so it's impossible to naively
> just add all of them to the interface like we've done so far.  I
> suspect that what we'll have to do is define a named property
> getter/setter/creator/deleter that handles all the existing properties
> and then additionally handles data properties.  Is this right?  The
> algorithm would be easy, since all we'd do is define the "camelCase to
> dash-separated" algorithm (already defined in HTML for dataset) and
> then rely on whether the UA recognizes the property or not.

(You're folding in CSS2Properties into CSSStyleDeclaration I guess.)

Yes, I think that's all you need.  Do you want to allow 
creation/deletion of properties here?  That would be new behaviour.  If 
not, then you can just have the getter/setter handle the data properties 
and leave the existing attributes to handle the fixed set of normal 
properties.

   interface CSSStyleDeclaration {
     getter DOMString (DOMString propertyName);
     setter void (DOMString propertyName, DOMString newValue);

     attribute DOMString fontSize;
     ...
   };

And then in prose:

   The set of _supported property names_ on a CSSStyleDeclaration object
   is the set of data property names on the object, blah blah dashes to
   uppercase, sorted alphabetically.

Or if you wanted to handle them all with the getter (because you want to 
simplify the IDL from how it is with CSS2Properties, or because you want 
to handle creators/deleters on them too) then just have prose like:

   The set of _supported property names_ on a CSSStyleDeclaration object
   is the union of the set of the names of the CSS properties the
   implementation supports, and the set of data property names on the
   object, converting dashes etc., sorted alphabetically.

(Note that Web IDL requires you to specify an ordering of the supported 
property names so that for..in does something predictable with them.)

> Additionally, I'd like to expose the set of valid data properties
> currently defined on the element.  I'm thinking something like a
> 'data' member on the interface which is nearly identical to what I
> described in the previous paragraph, but the getter only recognizes
> valid data properties on the element rather than all properties.

Then the former bit of prose is what you want on this object.  Plus the 
same getter/setter declarations.
Received on Monday, 14 November 2011 20:34:29 GMT

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