Opened 12 years ago

Closed 12 years ago

#10753 closed defect (fixed)

Widgets don't have unique ID's in multi-version environment

Reported by: Bryan Forbes Owned by: bill
Priority: high Milestone: 1.4.2
Component: Dijit Version: 1.4.0
Keywords: Cc:
Blocked By: Blocking:


In a multi-version environment, Dijit's ID generation routine will generate duplicate ID's. I'm attaching a test-case to highlight this.

Attachments (1)

multiversion.html (2.0 KB) - added by Bryan Forbes 12 years ago.

Download all attachments as: .zip

Change History (5)

Changed 12 years ago by Bryan Forbes

Attachment: multiversion.html added

comment:1 Changed 12 years ago by James Burke

Using dijit._scopeName in dijit.getUniqueId would fix it, although makes the ids longer.

comment:2 Changed 12 years ago by bill

Yes, modifying dijit.getUniqueId() solves one of the problems, avoiding clashes in generated id's.

I thought scopeMap could also solve the issue with portlets, where two widgets on the same page (but in different portlets) both have the same explicitly specified id, ie: id="foo". Like how iframes have a unique scope. That's a much bigger change though that needs more investigation, and wouldn't go into 1.4.2.

My original thought was to introduce a new (readonly) widget attribute:

this.scopeId = (dojo._scopeName == "dojo" ? "" : dojo._scopeName) +

and then use scopeId rather than id for anytime the widget id is read/written into the DOM. For example, use ${scopeId} rather than ${id} in templates, and then have code to strip dojo._scopeName in dijit.byNode().

It reminds me of the ContentPane issue where two ContentPane's load the same URL and start to get id clashes.

Note that there's a case for ComboBox where the id is used twice, applied to both the ComboBox.domNode (as "widget_foo") and the ComboBox.focusNode (as "foo"). And there's a case where the id from a ContentPane is used to generate the id of the corresponding TabButton. It's complicated.

comment:3 Changed 12 years ago by bill

OK, I'll checkin the fix for generated id's for 1.4, and leave the issue of specified id's for another day.

comment:4 Changed 12 years ago by bill

Resolution: fixed
Status: newclosed

(In [21444]) Make widget generated id's unique across multiversions of dojo. Fixes #10753 !strict.

Note: See TracTickets for help on using tickets.