[whatwg] repetition model

Dean Edwards dean at edwards.name
Sun Jun 13 14:25:20 PDT 2004


Ian Hickson wrote:
> 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!
> 
>>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?).
> 
i just checked. they show up as comments! but they are readable. so if 
you are concerned with IE compatibility we could use a PI.

> 
>>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'm not sure. i understand now how it is two DOM methods:

this:
<div id="hello-again" repeat="template">Hello World</div>
<repeat/>
<repeat/>
<repeat/>
<repeat/>

is equivalent to this:
<div id="hello-again" repeat="template">Hello World</div>
<script>
   var template = document.getElementById("hello-again");
   template.addRepetitionBlock();
   template.addRepetitionBlock();
   template.addRepetitionBlock();
   template.addRepetitionBlock();
</script>

i can see that one form is much nicer to read than the other. but only 
for a few elements. if i'm repeating a hundred rows it becomes easier in 
javascript (maybe add another attribute for the number of repeats?). i 
think if something like this does go in the markup then maybe it should 
be a PI. i'm just not convinced either way. what do others feel?

-dean







More information about the whatwg mailing list