Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Bug 389633 - Duplicated DOM IDs in outliner
--Signed-off-by: Elijah El-Haddad <elijahe@ca.ibm.com>
  • Loading branch information
elijahe committed Nov 15, 2013
1 parent 3c803a7 commit 8ccf4fa
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions bundles/org.eclipse.orion.client.ui/web/orion/outliner.js
Expand Up @@ -119,17 +119,20 @@ define([
return item.outlinerId;
}
// Generate an id. Since these id's are used in the DOM, we strip out characters that shouldn't be in a DOM id.
var id = item.label.replace(/[\\\/\.\:\-\_]/g, "");
var originalId = item.label.replace(/[\\\/\.\:\-\_]/g, "");
var id = originalId;
var number = 0;
// We might have duplicate id's if the outline items are duplicated, or if we happen to have another dom id using
// this name. Check for this case and use a timestamp in lieu of the generated id.
if ((this.idItemMap[id] && this.idItemMap[id]!== item) ||
while ((this.idItemMap[id] && this.idItemMap[id]!== item) ||
lib.node(id)) {// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=389760
id = new Date().getTime().toString();
this.idItemMap[id] = item;
item.outlinerId = id;
} else {
this.idItemMap[id] = item;
id = originalId + "[" + number + "]";
number = number + 1;
}

this.idItemMap[id] = item; //store the item
item.outlinerId = id; // cache the id

return id;
};

Expand Down

0 comments on commit 8ccf4fa

Please sign in to comment.