Merge pull request #7614 from KlausBenndorf/publicThisArgs

Remove opt_this from the API
This commit is contained in:
Tim Schaub
2017-12-19 09:30:54 -08:00
committed by GitHub
18 changed files with 72 additions and 135 deletions

View File

@@ -106,17 +106,6 @@ describe('ol.collection', function() {
expect(cb.callCount).to.eql(2);
});
});
describe('scope', function() {
it('callbacks get the correct scope', function() {
var collection = new _ol_Collection_([0]);
var that;
var uniqueObj = {};
collection.forEach(function(elem) {
that = this;
}, uniqueObj);
expect(that).to.be(uniqueObj);
});
});
});
describe('remove', function() {

View File

@@ -41,15 +41,6 @@ describe('ol.Observable', function() {
expect(listener.callCount).to.be(2);
});
it('accepts an optional `this` arg for the listener', function() {
var thisArg = {};
observable.on('foo', listener, thisArg);
observable.dispatchEvent('foo');
expect(listener.calledOnce).to.be(true);
expect(listener.calledOn(thisArg)).to.be(true);
});
it('returns a listener key', function() {
var key = observable.on('foo', listener);
@@ -106,15 +97,6 @@ describe('ol.Observable', function() {
expect(listener.callCount).to.be(2);
});
it('accepts an optional `this` arg for the listener', function() {
var thisArg = {};
observable.once('foo', listener, thisArg);
observable.dispatchEvent('foo');
expect(listener.calledOnce).to.be(true);
expect(listener.calledOn(thisArg)).to.be(true);
});
it('returns a listener key', function() {
var key = observable.once('foo', listener);
@@ -141,24 +123,6 @@ describe('ol.Observable', function() {
expect(listener.calledOnce).to.be(true);
});
it('accepts a `this` arg', function() {
var thisArg = {};
observable.on('foo', listener, thisArg);
observable.dispatchEvent('foo');
expect(listener.calledOnce).to.be(true);
// will not unregister without the same thisArg
observable.un('foo', listener);
observable.dispatchEvent('foo');
expect(listener.callCount).to.be(2);
// properly unregister by providing the same thisArg
observable.un('foo', listener, thisArg);
observable.dispatchEvent('foo');
expect(listener.callCount).to.be(2);
});
});
describe('ol.Observable.unByKey()', function() {

View File

@@ -253,18 +253,7 @@ describe('ol.source.TileUTFGrid', function() {
done();
};
source.forDataAtCoordinateAndResolution(
bonn3857, resolutionZoom1, callback, null, true
);
});
it('calls callback with correct `this` bound', function(done) {
var scope = {foo: 'bar'};
var callback = function(data) {
expect(this).to.be(scope);
done();
};
source.forDataAtCoordinateAndResolution(
bonn3857, resolutionZoom1, callback, scope, true
bonn3857, resolutionZoom1, callback, true
);
});
@@ -275,7 +264,7 @@ describe('ol.source.TileUTFGrid', function() {
done();
};
source.forDataAtCoordinateAndResolution(
noState3857, resolutionZoom1, callback, null, true
noState3857, resolutionZoom1, callback, true
);
});