[dojo-contributors] Re: stripped id tags

Bill Keese bill at dojotoolkit.org
Wed Apr 12 22:21:56 EDT 2006


Sorry, didn't see this till after I checked in... responses below.

Andy Smith wrote:
> My understanding was that you should be referring to the widget via
> dojo.widget.byId() anyway, 

That's generally true, although lots of people also want the id tag, so 
they can use things like <label>, etc.

Also if you want to map from a dom node back to the widget, it can only 
be done quickly (O(1)) if there is an id tag on the domnode, or a 
widgetId tag, etc.


> and that the code above functions as a
> safe-guard to prevent somebody from assigning the same ID to multiple
> instantiations of the widget (i.e. they hardcoded an id in the widget
> template).

Yup, you certainly shouldn't hardcode an id tag in a widget template. 
The problem is that the "safeguard" was also preventing people from 
using <label>, etc.

> 
> I personally would feel mildly worried if I saw <div
> id="${this.widgetId}">....</div> in a template because I would then
> expect a developer to be relying on something that changes shape
> somewhere in the middle of the page load.

Not sure what you are getting at here.  The whole point of the widget 
system is to change shape in the middle of page load.

Bill

> 
> On 4/8/06, Bill Keese <bill at dojotoolkit.org> wrote:
>> The widget instantiation code strips out any id tags in the template,
>> making templates like this impossible:
>>
>> <div id="${this.widgetId}">....</div>
>>
>> The culprit is this code from DomWidget.js:
>>
>> // strip IDs to prevent dupes. removeAttribute() doesnt care if
>> attribute doesnt exist
>> baseNode.removeAttribute('id');
>>
>> This must be referring to the source domnode vs. the target domnode, but
>> the code seems to do more harm than good, since in the typical case the
>> source domnode gets dropped anyway.
>>
>> Any objections if I remove that line?
>>
>> --
>>
>> Bill
>> _______________________________________________
>> dojo-contributors mailing list
>> dojo-contributors at dojotoolkit.org
>> http://dojotoolkit.org/mailman/listinfo/dojo-contributors
>>
> _______________________________________________
> dojo-contributors mailing list
> dojo-contributors at dojotoolkit.org
> http://dojotoolkit.org/mailman/listinfo/dojo-contributors

-- 

Bill



More information about the dojo-contributors mailing list