Fix ol.Collection#push return value #6220

Merged
merged 1 commit into from Dec 8, 2016

Projects

None yet

3 participants

@fredj
Member
fredj commented Dec 7, 2016

fixes #6219

@tchandelle
Contributor

As I mentioned in my comment #6219 (comment), would this be a case we should consider ?

var collection = new ol.Collection();

collection.on('add', function(event) {
  if (event.element === 'foo') {
    collection.remove(event.element);
  }
});

collection.push('foo'); // length is still 0
collection.push('bar'); // length is 1
@fredj fredj Fix ol.Collection#push return value
5e0ce08
@fredj
Member
fredj commented Dec 7, 2016

@tchandelle code updated. I've added a test for this case

@marcjansen

Looks good to me. Thanks and please merge

@fredj fredj merged commit e95778e into openlayers:master Dec 8, 2016

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
coverage/coveralls Coverage decreased (-0.008%) to 86.626%
Details
@fredj fredj deleted the fredj:collection_push_length branch Dec 8, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment