- From: Boris Zbarsky <bzbarsky@MIT.EDU>
- Date: Thu, 23 Aug 2012 18:12:55 -0700
- To: www-style@w3.org
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); Then your prose says that the set of supported property names is whatever that set is (e.g. for non-computed style it's variables that are in that declaration, I assume; for computed style it's whatever you define it to) and defines what the behavior of the getter and setter is for a given supported property name. If you want to allow creation of variables via this API, not just setting of existing ones, then you would change the second line above to: setter creator void (DOMString varName, DOMString varValue); If you also want to allow deletion of variables, you would add: deleter void (DOMString varName); Two caveats: 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. -Boris
Received on Friday, 24 August 2012 01:13:29 UTC