W3C home > Mailing lists > Public > public-script-coord@w3.org > July to September 2013

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

From: Simon Pieters <simonp@opera.com>
Date: Wed, 25 Sep 2013 15:30:39 +0200
To: "Anne van Kesteren" <annevk@annevk.nl>
Cc: "public-script-coord@w3.org" <public-script-coord@w3.org>
Message-ID: <op.w3yyhdvwidj3kv@simons-macbook-pro.local>
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

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 21:37:50 UTC