Bug 425079 - "Multiple back/forward buttons in toolbar" (don't create duplicate items, round two) [p=dao@mozilla.com (Dão Gottwald) r=gavin a=blocking-firefox3+]

This commit is contained in:
reed@reedloden.com 2008-04-04 02:03:05 -07:00
parent ccfd227e98
commit 7bb7f19f8d

View File

@ -179,12 +179,14 @@
if (val && val != "__empty") {
var itemIds = val.split(",");
var before = true;
this._trackInserted = {};
for (var i = 0; i < itemIds.length; i++) {
if (itemIds[i] == firstChildID || itemIds[i] == lastChildID)
before = false;
else
this.insertItem(itemIds[i], null, null, before);
}
delete this._trackInserted;
}
return val;
@ -223,6 +225,12 @@
newItem.id = "spacer" + uniqueId;
newItem.className = "chromeclass-toolbar-additional";
} else if (this.parentNode.localName == "toolbox") {
if (this._trackInserted) {
// Protect against creating an item with the given id more than once.
if (aId in this._trackInserted)
return false;
this._trackInserted[aId] = null;
}
// Attempt to locate an item with a matching id within palette.
var paletteItem = this.parentNode.palette.firstChild;
while (paletteItem) {