Re: [css3-regions] Improve the NamedFlow JS interface

On 2/7/12 4:06 AM, "Tab Atkins Jr." <jackalmage@gmail.com> wrote:

>The current NamedFlow interface seems very DOM0-y.  This isn't a good
>thing.  Here's the current interface:
>
>[Supplemental] interface Document {
>  NamedFlow getFlowByName(DOMString name);
>
>  NamedFlowCollection getNamedFlows();
>};  
>interface NamedFlowCollection {
>    readonly attribute unsigned long length;
>    caller getter NamedFlow item (in unsigned long index);
>};
>
>This would be *much* better exposed as a simple map of names to flows,
>something like the following:
>
>document.namedFlows
>  Returns a NamedFlowMap object for the Document representing the current
>CSS named flows (created by the 'flow-into' CSS property)
>
>interface NamedFlowMap {
>  getter Element (DOMString name);
>};
>
>The supported property names on a NamedFlowMap object at any instant are
>the names for each named flow in the document at that instant.
>
>To determine the value of a named property name in a NamedFlowMap, the
>user agent must return the NamedFlow object with the given name in the
>document.
>
>(Keep the current NamedFlow interface the same.)
>
>This version is much easier to use - if you have something like
>"flow-into: my-flow;" in the document, you can access it with
>"document.namedFlows['my-flow']".  Additionally, you can automatically
>enumerate the flows (this is specified in WebIDL), so you don't need to
>know the names ahead of time - just inspect the object, or use a for-in
>loop.
>
>~TJ

Tab,

Do you have any other arguments for maps and against collections? I'm not
convinced that this:

 document.namedFlows['my-flow'];

Is any easier than this:

 document.getFlowByName("my-flow");

The discussion on public-webapps [1] did not show a strong preference one
way or the other, except around collections being better for enumeration.
The use case I'm considering for enumeration is a script that ensures that
every named flow has an associated region chain, to make sure that all the
content is displayed.

So absent further discussion from you or others I'm inclined to keep these
interfaces as-is.

Thanks,

Alan

[1] http://lists.w3.org/Archives/Public/public-webapps/2012AprJun/0101.html

Received on Wednesday, 18 April 2012 00:46:04 UTC