aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorelijahe2013-11-15 16:26:30 (EST)
committerMark Macdonald2013-11-15 18:18:27 (EST)
commitbf9abe389cc63623b5868c2d9735df83d5d1f882 (patch)
treeab419cbc60ea2dea43e0e2bf8ed81fc8b02c6808
parentec8922a1286a69f256aab04a39b452eafb65096e (diff)
downloadorg.eclipse.orion.client-bf9abe389cc63623b5868c2d9735df83d5d1f882.zip
org.eclipse.orion.client-bf9abe389cc63623b5868c2d9735df83d5d1f882.tar.gz
org.eclipse.orion.client-bf9abe389cc63623b5868c2d9735df83d5d1f882.tar.bz2
Bug 389633 - Duplicated DOM IDs in outliner
--Signed-off-by: Elijah El-Haddad <elijahe@ca.ibm.com>
-rw-r--r--bundles/org.eclipse.orion.client.ui/web/orion/outliner.js17
1 files changed, 10 insertions, 7 deletions
diff --git a/bundles/org.eclipse.orion.client.ui/web/orion/outliner.js b/bundles/org.eclipse.orion.client.ui/web/orion/outliner.js
index 4914170..d2934ee 100644
--- a/bundles/org.eclipse.orion.client.ui/web/orion/outliner.js
+++ b/bundles/org.eclipse.orion.client.ui/web/orion/outliner.js
@@ -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;
};