protect for in loops with hasOwnProperty

This commit is contained in:
Bart van den Eijnden
2012-02-29 18:43:55 +01:00
parent d7a3ecac08
commit e3cc96dbfb
31 changed files with 385 additions and 266 deletions

View File

@@ -193,7 +193,9 @@ OpenLayers.Control.NavigationHistory = OpenLayers.Class(OpenLayers.Control, {
this.next.destroy();
this.deactivate();
for(var prop in this) {
this[prop] = null;
if (this.hasOwnProperty(prop)) {
this[prop] = null;
}
}
},
@@ -334,25 +336,27 @@ OpenLayers.Control.NavigationHistory = OpenLayers.Class(OpenLayers.Control, {
setListeners: function() {
this.listeners = {};
for(var type in this.registry) {
this.listeners[type] = OpenLayers.Function.bind(function() {
if(!this.restoring) {
var state = this.registry[type].apply(this, arguments);
this.previousStack.unshift(state);
if(this.previousStack.length > 1) {
this.onPreviousChange(
this.previousStack[1], this.previousStack.length - 1
);
if (this.registry.hasOwnProperty(type)) {
this.listeners[type] = OpenLayers.Function.bind(function() {
if(!this.restoring) {
var state = this.registry[type].apply(this, arguments);
this.previousStack.unshift(state);
if(this.previousStack.length > 1) {
this.onPreviousChange(
this.previousStack[1], this.previousStack.length - 1
);
}
if(this.previousStack.length > (this.limit + 1)) {
this.previousStack.pop();
}
if(this.nextStack.length > 0) {
this.nextStack = [];
this.onNextChange(null, 0);
}
}
if(this.previousStack.length > (this.limit + 1)) {
this.previousStack.pop();
}
if(this.nextStack.length > 0) {
this.nextStack = [];
this.onNextChange(null, 0);
}
}
return true;
}, this);
return true;
}, this);
}
}
},
@@ -371,7 +375,9 @@ OpenLayers.Control.NavigationHistory = OpenLayers.Class(OpenLayers.Control, {
this.setListeners();
}
for(var type in this.listeners) {
this.map.events.register(type, this, this.listeners[type]);
if (this.listeners.hasOwnProperty(type)) {
this.map.events.register(type, this, this.listeners[type]);
}
}
activated = true;
if(this.previousStack.length == 0) {
@@ -405,9 +411,11 @@ OpenLayers.Control.NavigationHistory = OpenLayers.Class(OpenLayers.Control, {
if(this.map) {
if(OpenLayers.Control.prototype.deactivate.apply(this)) {
for(var type in this.listeners) {
this.map.events.unregister(
type, this, this.listeners[type]
);
if (this.listeners.hasOwnProperty(type)) {
this.map.events.unregister(
type, this, this.listeners[type]
);
}
}
if(this.clearOnDeactivate) {
this.clear();