Re: [css-regions] Reworking getNamedFlows()

On 7/29/13 9:30 AM, "Tab Atkins Jr." <jackalmage@gmail.com> wrote:

>On Mon, Jul 29, 2013 at 6:46 AM, Mihnea-Vlad Ovidenie <mihnea@adobe.com>
>wrote:
>> François REMY <francois.remy.dev@outlook.com> wrote:
>>> I would prefer getNamedFlows() to return a [MapLike] object instead of
>>>this
>>> hybrid collection with getters.
>>
>> This is something that was brought in the past (1).  At this moment, the
>> NamedFlowsCollection interface is modeled to resemble the HTMLCollection
>> interface.
>> Previous discussions on NamedFlowsCollection can be found at [2] and
>>[3].
>
>HTMLCollection is a legacy interface and is not meant to be emulated.
>TC39 warns against designing "catch-all" object interfaces like this,
>for the precise reasons that François outlines: you can't have
>language-defined methods or attributes on the object or its prototypes
>without either risking them being overwritten by user code, or
>explicitly preventing user code from overriding them.  Both are bad
>when we have ways to avoid them, and the latter is a future-compat
>hazard.  Further, they don't play nicely with the newer iterator-based
>things in JS.
>
>This is precisely why I proposed [MapLike] and WebIDL and got it added.

OK, coming back to this. If we go the Map route, then I'm assuming it's a
static, read-only map. Would something like this work?

-----
The NamedFlowMap interface provides a map of current NamedFlow instances
in the document. A NamedFlowMap object is a snapshot of the data, and is
read-only.

[MapClass(DOMString, NamedFlow)]
interface NamedFlowMap {
  NamedFlow get(DOMString flowName);
  boolean has(DOMString flowName);
}

The map entries in a NamedFlowMap object are the named flow idents paired
with their NamedFlow objects. The set() and delete() methods on this
interface always throw an InvalidAccessError exception. The NamedFlowMap
interface uses the rest of the default map class methods [1]
-----

Is throwing that exception on set() and delete() the correct thing to do
for a read-only Map? Do I need to declare the set() and delete() methods
in the interface? Should I also define an error for clear()?

Thanks,

Alan

[1] http://dev.w3.org/2006/webapi/WebIDL/#es-map-members

Received on Monday, 14 October 2013 22:10:14 UTC