[whatwg] repetition model

Ian Hickson ian at hixie.ch
Sun Jun 13 12:43:14 PDT 2004

(Note: I'm going through all the Web Forms 2 comments that were sent to
this list in chronological order. At the moment I'm dealing with e-mails
from last Thursday.)

On Thu, 10 Jun 2004, Dean Edwards wrote:
> but i have some reservations. i'm confused by the <repeat> element. this
> is the first time i've seen such a construct in an xml language. if this
> kind of construct is normal, please ignore the rest of my comments and
> direct me to a suitable resource so i can do some reading!
> my main reservation is that, for the first time, my DOM does not look
> exactly like my markup.

<script> blocks have long been able to change the DOM during parse time.
There are also some bugs in IE that cause it to remove entire elements
from the DOM (in particular <object>) under certain conditions. So it's
not the first time, per se. :-)

I agree it is odd though.

> now i have this "repeat" element. does it show up in the DOM?

It's well defined:


As soon as the <repeat> element is inserted into the document, whether by
being in the original markup or via scripting, a repetition block is
inserted into the DOM at the appropriate place, and the <repeat> element
is then removed.

I agree it is a bit unusual. I don't really see another way to do it
though. Suggestions are welcome.

> presumably generated rows and form controls do.


> can i do this?
>    document.createElement("repeat");
> will that throw an error?

You can do it and it won't cause an error. If you try to insert it into
the document using, e.g., appendChild(), then the element will be replaced
by a repetition block in the final DOM, as described in the spec above.

> it seems like the <repeat> element is more like a programming
> instruction than real content.

True. We could use a PI instead, but I don't think IE supports that (you
wouldn't be able to tell there was a PI in the DOM, right?).

> this takes (X)HTML in a new direction.

That's the intention of the WHATWG. :-)

> imho, something like the <repeat> construct belongs in the realm of
> jsp/asp/php. maybe this functionality can be included as a DOM method
> for completeness?

It is a DOM method too. In fact, it's defined in terms of two DOM methods.
And it could indeed be done on the server side, although it would be a
lot uglier.

Should I just remove it for now?

I don't really see what to replace it with. It's a rather important part
of the demo in the introduction:


Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'

More information about the whatwg mailing list