aboutsummaryrefslogtreecommitdiff
path: root/node_modules/tools/template
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/tools/template')
-rwxr-xr-xnode_modules/tools/template/template-creator.js13
1 files changed, 8 insertions, 5 deletions
diff --git a/node_modules/tools/template/template-creator.js b/node_modules/tools/template/template-creator.js
index 374353f0..dc6b1190 100755
--- a/node_modules/tools/template/template-creator.js
+++ b/node_modules/tools/template/template-creator.js
@@ -51,8 +51,8 @@ var TemplateCreator = exports.TemplateCreator = Montage.create(Template, /** @le
51 component = isRootNode ? null : sourceNode.controller; 51 component = isRootNode ? null : sourceNode.controller;
52 52
53 if (component) { 53 if (component) {
54 label = self._generateLabelForComponent(component);
55 targetNode.setAttribute("id", label); 54 targetNode.setAttribute("id", label);
55 label = self._generateLabelForComponent(component, Object.keys(components));
56 component._element = targetNode; 56 component._element = targetNode;
57 components[label] = component; 57 components[label] = component;
58 } else { 58 } else {
@@ -94,8 +94,8 @@ var TemplateCreator = exports.TemplateCreator = Montage.create(Template, /** @le
94 _componentNamesIndex: { 94 _componentNamesIndex: {
95 value: null 95 value: null
96 }, 96 },
97 97
98 _generateLabelForComponent: {value: function(component) { 98 _generateLabelForComponent: {value: function(component, labels) {
99 var componentInfo = Montage.getInfoForObject(component), 99 var componentInfo = Montage.getInfoForObject(component),
100 componentLabel = componentInfo.label, 100 componentLabel = componentInfo.label,
101 componentName, 101 componentName,
@@ -105,8 +105,11 @@ var TemplateCreator = exports.TemplateCreator = Montage.create(Template, /** @le
105 return componentLabel; 105 return componentLabel;
106 } else { 106 } else {
107 componentName = componentInfo.objectName.toLowerCase(); 107 componentName = componentInfo.objectName.toLowerCase();
108 index = this._componentNamesIndex[componentName] || 1; 108 do {
109 this._componentNamesIndex[componentName] = index + 1; 109 index = this._componentNamesIndex[componentName] || 1;
110 this._componentNamesIndex[componentName] = index + 1;
111 } while (labels.indexOf(componentName+index) >= 0);
112
110 return componentName + index; 113 return componentName + index;
111 } 114 }
112 }}, 115 }},