How to specify an object that can be mutable or immutable

Hi

CSSOM View has a DOMRect interface [1], representing a rectangle. As part  
of adding new features, it was proposed to make the attributes of DOMRect  
mutable (for convenience, instead of having to create a new object), but  
in some situations they should be immutable. The question is how to best  
specify this.

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 [2] is an example that always throws.

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. [3]

WDYT?

[1] http://dev.w3.org/csswg/cssom-view/#the-domrect-interface
[2] http://dev.w3.org/csswg/cssom/#dom-cssstyledeclaration-csstext
[3] http://www.w3.org/mid/52426F6E.5070204@mit.edu
-- 
Simon Pieters
Opera Software

Received on Wednesday, 25 September 2013 09:21:58 UTC