protect for in loops with hasOwnProperty
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user