Merge pull request #3845 from fredj/collection_null_array

Prevent null array to be passed to an ol.Collection
This commit is contained in:
Frédéric Junod
2015-06-25 09:25:37 +02:00
2 changed files with 6 additions and 6 deletions
+4 -4
View File
@@ -79,7 +79,7 @@ ol.CollectionProperty = {
* @constructor * @constructor
* @extends {ol.Object} * @extends {ol.Object}
* @fires ol.CollectionEvent * @fires ol.CollectionEvent
* @param {Array.<T>=} opt_array Array. * @param {!Array.<T>=} opt_array Array.
* @template T * @template T
* @api stable * @api stable
*/ */
@@ -89,7 +89,7 @@ ol.Collection = function(opt_array) {
/** /**
* @private * @private
* @type {Array.<T>} * @type {!Array.<T>}
*/ */
this.array_ = goog.isDef(opt_array) ? opt_array : []; this.array_ = goog.isDef(opt_array) ? opt_array : [];
@@ -113,7 +113,7 @@ ol.Collection.prototype.clear = function() {
/** /**
* Add elements to the collection. This pushes each item in the provided array * Add elements to the collection. This pushes each item in the provided array
* to the end of the collection. * to the end of the collection.
* @param {Array.<T>} arr Array. * @param {!Array.<T>} arr Array.
* @return {ol.Collection.<T>} This collection. * @return {ol.Collection.<T>} This collection.
* @api stable * @api stable
*/ */
@@ -145,7 +145,7 @@ ol.Collection.prototype.forEach = function(f, opt_this) {
* is mutated, no events will be dispatched by the collection, and the * is mutated, no events will be dispatched by the collection, and the
* collection's "length" property won't be in sync with the actual length * collection's "length" property won't be in sync with the actual length
* of the array. * of the array.
* @return {Array.<T>} Array. * @return {!Array.<T>} Array.
* @api stable * @api stable
*/ */
ol.Collection.prototype.getArray = function() { ol.Collection.prototype.getArray = function() {
+2 -2
View File
@@ -221,8 +221,8 @@ ol.interaction.Select.handleEvent = function(mapBrowserEvent) {
var set = !add && !remove && !toggle; var set = !add && !remove && !toggle;
var map = mapBrowserEvent.map; var map = mapBrowserEvent.map;
var features = this.featureOverlay_.getSource().getFeaturesCollection(); var features = this.featureOverlay_.getSource().getFeaturesCollection();
var /** @type {Array.<ol.Feature>} */ deselected = []; var /** @type {!Array.<ol.Feature>} */ deselected = [];
var /** @type {Array.<ol.Feature>} */ selected = []; var /** @type {!Array.<ol.Feature>} */ selected = [];
var change = false; var change = false;
if (set) { if (set) {
// Replace the currently selected feature(s) with the feature(s) at the // Replace the currently selected feature(s) with the feature(s) at the