Merge pull request #461 from tschaub/ie9-leaks

OpenLayers-2.12-rc2 + jQuery-1.7.2 Memory leak in Internet Explorer 9 (p=@tschaub,r=@marcjansen,@elemoine)
This commit is contained in:
Marc Jansen
2013-04-03 02:43:48 -07:00
2 changed files with 12 additions and 13 deletions

View File

@@ -45,8 +45,15 @@ OpenLayers.Control.Geolocate = OpenLayers.Class(OpenLayers.Control, {
/**
* Property: geolocation
* {Object} The geolocation engine, as a property to be possibly mocked.
* This is set lazily to avoid a memory leak in IE9.
*/
geolocation: navigator.geolocation,
geolocation: null,
/**
* Property: available
* {Boolean} The navigator.geolocation object is available.
*/
available: ('geolocation' in navigator),
/**
* APIProperty: bind
@@ -90,6 +97,10 @@ OpenLayers.Control.Geolocate = OpenLayers.Class(OpenLayers.Control, {
* {Boolean} The control was effectively activated.
*/
activate: function () {
if (this.available && !this.geolocation) {
// set lazily to avoid IE9 memory leak
this.geolocation = navigator.geolocation;
}
if (!this.geolocation) {
this.events.triggerEvent("locationuncapable");
return false;