Re: How to specify an object that can be mutable or immutable

On Wed, 25 Sep 2013 14:56:07 +0200, Anne van Kesteren <annevk@annevk.nl>  
wrote:

> On Wed, Sep 25, 2013 at 5:21 AM, Simon Pieters <simonp@opera.com> wrote:
>> Traditionally, I think DOM specs have just required to either throw or  
>> no-op
>> in the immutable state, regardless of JS strict mode. CSSOM's
>> CSSStyleDeclaration#cssText attribute is an example that always throws.
>
> Are there any other examples that are not killed off?

There are more examples in CSSOM at least. CSSStyleDeclaration's  
camel-cased attributes are defined to invoke setProperty and throw any  
exception that throws, which depends on the readonly flag.

SVG's animatable attributes do this.  
http://www.w3.org/mid/22867ED9-64FB-475C-B277-CAA3B1B5FF81@adobe.com


>
>> Boris Zbarsky suggested it might be better to have two separate  
>> interfaces,
>> with the mutable interface has settable attributes and the immutable
>> interface has readonly attributes.
>
> We do this for URL: http://url.spec.whatwg.org/#api

Ah, OK. It's not quite the same since they use [NoInterfaceObject] and  
implements, whereas DOMRect and DOMRectReadOnly would presumably be normal  
interfaces.

-- 
Simon Pieters
Opera Software

Received on Wednesday, 25 September 2013 13:31:15 UTC