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

On Thu, Aug 23, 2012 at 6:12 PM, Boris Zbarsky <bzbarsky@mit.edu> wrote:
> On 8/23/12 5:46 PM, Tab Atkins Jr. wrote:
>>
>> How can we do this in WebIDL?
>
> You can declare getters and setters that would live directly on the object
> in WebIDL to support open-ended sets of properties.  So basically something
> like this:
>
>   getter DOMString (DOMString varName);
>   setter void (DOMString varName, DOMString varValue);

That works nicely with the existing attributes, I assume?  Or do I
need to write the getter/setter to handle them as well?

> 1)  The interaction with web content that sets expandos on CSS declarations
> might be interesting.  Let's hope there's not too much of it.
>
> 2)  Using a getter and setter as above will not allow variable names to
> shadow properties on the proto chain.  So if you have a variable named
> getProperty, doing style.getProperty will still get you the function off the
> prototype.  And if you have a variable named "display", then style.display
> will still be the display property value, not the value of the variable.  I
> think this is in fact the behavior we want here.

Neither of these should be much of a problem.  All custom property
have a "var-" prefix, which translates to a "var and a capital letter"
prefix as a property.  So, I can just require that structure in the
getter/etc and bail otherwise.

~TJ

Received on Friday, 24 August 2012 01:23:25 UTC