Always provide useCapture and async args to browser

This commit is contained in:
Andreas Hocevar
2016-01-29 17:04:34 +01:00
parent f35d0106b8
commit d7497f9686
4 changed files with 8 additions and 7 deletions

View File

@@ -105,7 +105,7 @@ ol.events.createListenOnce_ = function(target, type, listener, opt_useCapture, o
var key = ol.events.getKey.apply(undefined, arguments);
return function listenOnce(evt) {
listener.call(opt_this || this, evt);
target.removeEventListener(evt.type, listenOnce, opt_useCapture);
target.removeEventListener(evt.type, listenOnce, !!opt_useCapture);
--count;
if (count === 0) {
delete ol.events.listenersByKey_[key];
@@ -177,7 +177,7 @@ ol.events.listen = function(target, type, listener, opt_useCapture, opt_this) {
var key = ol.events.getKey.apply(undefined, arguments);
if (!ol.events.listenersByKey_[key]) {
for (var i = 0, ii = types.length; i < ii; ++i) {
target.addEventListener(types[i], targetListener, opt_useCapture);
target.addEventListener(types[i], targetListener, !!opt_useCapture);
}
ol.events.listenersByKey_[key] = /** @type {ol.events.ListenerData} */ ({
listener: targetListener,
@@ -248,7 +248,7 @@ ol.events.unlistenByKey = function(key) {
var types = Array.isArray(type) ? type : [type];
for (var i = 0, ii = types.length; i < ii; ++i) {
listenerData.target.removeEventListener(types[i],
listenerData.listener, listenerData.useCapture);
listenerData.listener, !!listenerData.useCapture);
}
delete ol.events.listenersByKey_[key];
}

View File

@@ -65,7 +65,8 @@ ol.featureloader.loadFeaturesXhr = function(url, format, success, failure) {
function(extent, resolution, projection) {
var xhr = new XMLHttpRequest();
xhr.open('GET',
goog.isFunction(url) ? url(extent, resolution, projection) : url);
goog.isFunction(url) ? url(extent, resolution, projection) : url,
true);
if (format.getType() == ol.format.FormatType.ARRAY_BUFFER) {
xhr.responseType = 'arraybuffer';
}

View File

@@ -1063,7 +1063,7 @@ ol.Map.prototype.handleTargetChanged_ = function() {
goog.dom.removeNode(this.viewport_);
if (this.handleResize_ !== undefined) {
goog.global.removeEventListener(ol.events.EventType.RESIZE,
this.handleResize_);
this.handleResize_, false);
this.handleResize_ = undefined;
}
} else {
@@ -1078,7 +1078,7 @@ ol.Map.prototype.handleTargetChanged_ = function() {
if (!this.handleResize_) {
this.handleResize_ = this.updateSize.bind(this);
goog.global.addEventListener(ol.events.EventType.RESIZE,
this.handleResize_);
this.handleResize_, false);
}
}

View File

@@ -44,7 +44,7 @@ ol.source.TileJSON = function(options) {
this.handleTileJSONError.bind(this));
} else {
var xhr = new XMLHttpRequest();
xhr.open('GET', options.url);
xhr.open('GET', options.url, true);
xhr.onload = function(e) {
if (xhr.status < 400) {
var response = /** @type {TileJSON} */(JSON.parse(xhr.responseText));