Re: [css-regions] Reworking getNamedFlows()

On Mon, Oct 14, 2013 at 3:08 PM, Alan Stearns <stearns@adobe.com> wrote:
> 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?

Is there a particular reason for it to be static?  I assume that the
current spec's interface is live, right?

> 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]

Right.

> 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?

Yes and yes - throw an exception, and you have to do so by manually
specifying those methods.

> Should I also define an error for clear()?

No, the default implementation of clear() is defined in terms of the
iterator and delete(), so you're covered.

(Technically, this means that clear() won't throw if the Map is empty,
but whatever.)

~TJ

Received on Tuesday, 15 October 2013 17:44:17 UTC