Don't do forEach loop twice

This commit is contained in:
Piro / YUKI Hiroshi 2014-03-29 02:18:44 +09:00
parent 4f80fb7f97
commit 2c603b7558

View File

@ -73,7 +73,7 @@ BrowserUIShowHideObserver.prototype = {
return; return;
case 'attributes': case 'attributes':
this.onAttributeModified(this.box, aMutations, aObserver); this.onAttributeModified(this.box, aMutation, aObserver);
return; return;
} }
}, this); }, this);
@ -99,13 +99,15 @@ BrowserUIShowHideObserver.prototype = {
var self = this; var self = this;
observer = new this.MutationObserver(function(aMutations, aObserver) { observer = new this.MutationObserver(function(aMutations, aObserver) {
self.onAttributeModified(aChild, aMutations, aObserver); aMutations.forEach(function(aMutation) {
self.onAttributeModified(aChild, aMutation, aObserver);
});
}); });
observer.observe(aChild, { attributes : true }); observer.observe(aChild, { attributes : true });
aChild.__treestyletab__attributeObserver = observer; aChild.__treestyletab__attributeObserver = observer;
}, this) }, this)
}, },
onAttributeModified : function BrowserUIShowHideObserver_onAttributeModified(aTargetElement, aMutations, aObserver) onAttributeModified : function BrowserUIShowHideObserver_onAttributeModified(aTargetElement, aMutation, aObserver)
{ {
var TST = this.owner.browser.treeStyleTab; var TST = this.owner.browser.treeStyleTab;
if ( if (
@ -121,16 +123,12 @@ BrowserUIShowHideObserver.prototype = {
) )
return; return;
aMutations.forEach(function(aMutation) {
if (aMutation.type != 'attributes')
return;
if (aMutation.attributeName == 'hidden' || if (aMutation.attributeName == 'hidden' ||
aMutation.attributeName == 'collapsed' || aMutation.attributeName == 'collapsed' ||
aMutation.attributeName == 'moz-collapsed' || // Used in full screen mode aMutation.attributeName == 'moz-collapsed' || // Used in full screen mode
aMutation.attributeName == 'disablechrome') { aMutation.attributeName == 'disablechrome') {
TST.updateFloatingTabbar(TreeStyleTabConstants.kTABBAR_UPDATE_BY_WINDOW_RESIZE); TST.updateFloatingTabbar(TreeStyleTabConstants.kTABBAR_UPDATE_BY_WINDOW_RESIZE);
} }
}, this);
}, },
destroyChildrenObserver : function BrowserUIShowHideObserver_destroyChildrenObserver(aParent) destroyChildrenObserver : function BrowserUIShowHideObserver_destroyChildrenObserver(aParent)