aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsfranklin2012-06-11 12:47:17 (EDT)
committerMark Macdonald2012-06-11 14:14:50 (EDT)
commitb67e1fc30ceedc966b66f3f39304164c282a2be5 (patch)
tree752e7b23741446d25dbe8c9e01469d6b992c8bb4
parent4bc774febf6a910a3e0e9bef5976068379fe4681 (diff)
downloadorg.eclipse.orion.client-b67e1fc30ceedc966b66f3f39304164c282a2be5.zip
org.eclipse.orion.client-b67e1fc30ceedc966b66f3f39304164c282a2be5.tar.gz
org.eclipse.orion.client-b67e1fc30ceedc966b66f3f39304164c282a2be5.tar.bz2
Bug 380823 - Actions menu leaks DOM elements
-rw-r--r--bundles/org.eclipse.orion.client.core/web/orion/commands.js21
-rw-r--r--bundles/org.eclipse.orion.client.core/web/orion/fileCommands.js12
2 files changed, 27 insertions, 6 deletions
diff --git a/bundles/org.eclipse.orion.client.core/web/orion/commands.js b/bundles/org.eclipse.orion.client.core/web/orion/commands.js
index 6ffa6d0..9040627 100644
--- a/bundles/org.eclipse.orion.client.core/web/orion/commands.js
+++ b/bundles/org.eclipse.orion.client.core/web/orion/commands.js
@@ -759,6 +759,27 @@ define(['i18n!orion/nls/messages', 'require', 'dojo', 'dijit', 'orion/util', 'or
}
},
+ /**
+ * Destroy all DOM nodes and any other resources used by rendered commands.
+ * This call does not remove the commands from the command registry. Clients typically call this
+ * function to empty a command area when a client wants to render the commands again due to some
+ * change in state.
+ * @param {String|DOMElement} parent The id or DOM node that should be emptied.
+ */
+ destroy: function(parent) {
+ if (typeof(parent) === "string") { //$NON-NLS-0$
+ parent = dojo.byId(parent);
+ }
+ if (!parent) {
+ throw "no parent"; //$NON-NLS-0$
+ }
+ var widgets = dijit.findWidgets(parent);
+ dojo.forEach(widgets, function(w) {
+ w.destroyRecursive();
+ });
+ dojo.empty(parent);
+ },
+
_render: function(contributions, parent, items, handler, renderType, userData, domNodeWrapperList) {
// sort the items
var sortedByPosition = contributions.sortedContributions;
diff --git a/bundles/org.eclipse.orion.client.core/web/orion/fileCommands.js b/bundles/org.eclipse.orion.client.core/web/orion/fileCommands.js
index e6a9419..60f298f 100644
--- a/bundles/org.eclipse.orion.client.core/web/orion/fileCommands.js
+++ b/bundles/org.eclipse.orion.client.core/web/orion/fileCommands.js
@@ -69,13 +69,13 @@ define(['i18n!orion/navigate/nls/messages', "require", "dojo", "orion/util", "or
* @function
*/
fileCommandUtils.updateNavTools = function(registry, explorer, toolbarId, selectionToolbarId, item) {
+ var service = registry.getService("orion.page.command"); //$NON-NLS-0$
var toolbar = dojo.byId(toolbarId);
if (toolbar) {
- dojo.empty(toolbar);
+ service.destroy(toolbar);
} else {
throw messages["could not find toolbar "] + toolbarId;
}
- var service = registry.getService("orion.page.command"); //$NON-NLS-0$
// close any open slideouts because if we are retargeting the command
if (item.Location !== lastItemLoaded.Location) {
service.closeParameterCollector();
@@ -90,8 +90,8 @@ define(['i18n!orion/navigate/nls/messages', "require", "dojo", "orion/util", "or
if (selectionToolbarId) {
var selectionTools = dojo.byId(selectionToolbarId);
if (selectionTools) {
- dojo.empty(selectionToolbarId);
- service.renderCommands(selectionToolbarId, selectionToolbarId, null, explorer, "button"); //$NON-NLS-0$
+ service.destroy(selectionTools);
+ service.renderCommands(selectionToolbarId, selectionTools, null, explorer, "button"); //$NON-NLS-0$
}
}
@@ -102,8 +102,8 @@ define(['i18n!orion/navigate/nls/messages', "require", "dojo", "orion/util", "or
selectionService.addEventListener("selectionChanged", function(singleSelection, selections) { //$NON-NLS-0$
var selectionTools = dojo.byId(selectionToolbarId);
if (selectionTools) {
- dojo.empty(selectionTools);
- registry.getService("orion.page.command").renderCommands(selectionTools.id, selectionTools, selections, explorer, "button"); //$NON-NLS-1$ //$NON-NLS-0$
+ service.destroy(selectionTools);
+ service.renderCommands(selectionTools.id, selectionTools, selections, explorer, "button"); //$NON-NLS-1$ //$NON-NLS-0$
}
});
}