Re: Making <switch> useful

Hello Alex,

Tuesday, September 10, 2013, 7:45:14 PM, you wrote:

> The clever thing about switch (that it exits processing after the  
> first "matching" child) is also its hang-up when working at any scale.
> It's only good for single elements.

No. First child does not equal single element. An element includes the
start tag, the content (if any) the children (if any) and the end tag
(if it needs one).

>  In practice, it would be more
> useful to evaluate on groups.

In your example, the g elements are children of switch and the first
one to evaluate to true gets rendered. Including, of course, all of
its children.

> I want to be able to write:

> <svg>
>  <switch>
>      <g media="(max-width: 10em)">
>          <path />
>          <path />
>          <path />
>      </g>
>      <g media="(max-width: 18em)">
>          <path />
>          <path />
>          <path />
>      </g>
>      <g media="(max-width: 45em)">
>          <path />
>          <path />
>          <path />
>      </g>
>      // fallback & accessibility
>      <g>
>          <path />
>          <path />
>          <path />
>      </g>
>    </switch>
> </svg>

Assuming media are added as testable attributes for switch, then your
example is fine already. No exgtension needed to allow groups or to
allow child elments of the selected first child of switch.

If that isn't clear then maybe the relevant parts of the SVG spec
(which was written with the assumption that people understood xml)
needs to be clarified.

To reiterate, first child can be a container element. It is not at all
restricted to single elements without children.



-- 
Best regards,
 Chris                            mailto:chris@w3.org

Received on Tuesday, 10 September 2013 23:24:15 UTC