[whatwg] Suggestion: "context" attribute

Martin Kutschker wrote:
> ------------------------------------------------------------
> 
> <div id="myPopup" popup="popup">
> <p>Random popup stuff</p>
> </div>
> 
> <input type="text" value="some text" context="myPopup">
> 
> ------------------------------------------------------------

    I see, you object to the abuse of the "repeat" attribute. The 
problem here is we now have two attributes that effectively define the 
same concept: "repeat" and "popup". I'm not sure if you've read the 
other thread I posted, but I prefer the following solution:

------------------------------------------------------------

<template id="myPopup"><!--
   <div>
    <p>Random popup stuff</p>
   </div>
--></template>

<input type="text" value="some text" context="myPopup">

------------------------------------------------------------

    This fixes the following problems:

1) It doesn't require multiple attribute definitions that use the same 
concept: templates.

2) Since the contents of template are commented, legacy UAs won't render 
it. The template element itself will be ignored by legacy UAs. So, 
basically, this approach makes templates nonvisible of all UAs, unless 
someone goes out of their way in to make the element visible. (Note that 
the repeat="template" method requires both support for CSS and the use 
of styling by the author to hide the template. Also, the styling in 
question, which is listed in the WF2 spec, doesn't seem to work in IE 6.0.)

3) It's significantly easier for a web author to figure out that the 
<div> block above is actually a template.

4) Since DOM supports access to comments, UAs with DOM and scripting 
support can use a script to read the contents of <template> and generate 
a popup accordingly.

> I've had no problems with "context". But I'm stricly against rehashing
 > elements or attributes. Especially if it's semantically an abuse.

    Well, with the solution above, the "repeat" attribute is only used 
for non-templates, so you get something like this:

------------------------------------------------------------

<template id="myItem"><!--
   <div id="myDiv[myItem]">...Stuff...</div>
--></template>

<repeat>
<div id="myDiv1" repeat="1">...Custom Stuff...</div>
<repeat>
<div id="myDiv3" repeat="3">...More Custom Stuff...</div>
<repeat>
<repeat>

------------------------------------------------------------

    As you see, the repeat attribute, when used in conjunction with a 
<template> element, only has numerical values. I would argue that this 
makes the attribute even more pure than it was before.

> Because it was not meant for this and 'repeat="tenplate"' makes
 > abosultely no sense for a popup. The naming is confusing.

    Using <template> fixes that.

> Well, Mozilla can handle unnown tags :-) But you're right introducing
 > elements shouldn't be done light heartedly.

    The nice thing about the <template> solution is that for the price 
of a single additional element, you eliminate part of an attribute and 
gain additional flexibility.

> I didn't object to "context". Though I doubt if reusung a XUL attribute
 > has any benefits. So this is the same to me:
> 
> ------------------------------------------------------------
> 
> <input type="text" value="some text" popupid="myPopup">
> 
> ------------------------------------------------------------

    I have a slight preference for "context", but it's really important 
so long as the web author knows what the attribute does.

Received on Saturday, 26 June 2004 04:59:41 UTC