Merge pull request #4804 from fredj/rm_goog.isArray
Use Array.isArray instead of goog.isArray
This commit is contained in:
@@ -169,7 +169,7 @@ ol.array.reverseSubArray = function(arr, begin, end) {
|
||||
*/
|
||||
ol.array.flatten = function(arr) {
|
||||
var data = arr.reduce(function(flattened, value) {
|
||||
if (goog.isArray(value)) {
|
||||
if (Array.isArray(value)) {
|
||||
return flattened.concat(ol.array.flatten(value));
|
||||
} else {
|
||||
return flattened.concat(value);
|
||||
|
||||
@@ -61,7 +61,7 @@ ol.color.rgbaColorRe_ =
|
||||
* @api
|
||||
*/
|
||||
ol.color.asArray = function(color) {
|
||||
if (goog.isArray(color)) {
|
||||
if (Array.isArray(color)) {
|
||||
return color;
|
||||
} else {
|
||||
goog.asserts.assert(typeof color === 'string', 'Color should be a string');
|
||||
@@ -80,7 +80,7 @@ ol.color.asString = function(color) {
|
||||
if (typeof color === 'string') {
|
||||
return color;
|
||||
} else {
|
||||
goog.asserts.assert(goog.isArray(color), 'Color should be an array');
|
||||
goog.asserts.assert(Array.isArray(color), 'Color should be an array');
|
||||
return ol.color.toString(color);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -314,7 +314,7 @@ ol.Feature.createStyleFunction = function(obj) {
|
||||
* @type {Array.<ol.style.Style>}
|
||||
*/
|
||||
var styles;
|
||||
if (goog.isArray(obj)) {
|
||||
if (Array.isArray(obj)) {
|
||||
styles = obj;
|
||||
} else {
|
||||
goog.asserts.assertInstanceof(obj, ol.style.Style,
|
||||
|
||||
@@ -170,7 +170,7 @@ ol.format.EsriJSON.readPointGeometry_ = function(object) {
|
||||
* @return {ol.geom.Geometry} LineString.
|
||||
*/
|
||||
ol.format.EsriJSON.readLineStringGeometry_ = function(object) {
|
||||
goog.asserts.assert(goog.isArray(object.paths),
|
||||
goog.asserts.assert(Array.isArray(object.paths),
|
||||
'object.paths should be an array');
|
||||
goog.asserts.assert(object.paths.length === 1,
|
||||
'object.paths array length should be 1');
|
||||
@@ -185,7 +185,7 @@ ol.format.EsriJSON.readLineStringGeometry_ = function(object) {
|
||||
* @return {ol.geom.Geometry} MultiLineString.
|
||||
*/
|
||||
ol.format.EsriJSON.readMultiLineStringGeometry_ = function(object) {
|
||||
goog.asserts.assert(goog.isArray(object.paths),
|
||||
goog.asserts.assert(Array.isArray(object.paths),
|
||||
'object.paths should be an array');
|
||||
goog.asserts.assert(object.paths.length > 1,
|
||||
'object.paths array length should be more than 1');
|
||||
|
||||
@@ -203,7 +203,7 @@ ol.format.Feature.transformWithOptions = function(
|
||||
return coordinates;
|
||||
};
|
||||
if (Array.isArray(transformed)) {
|
||||
transform(/** @type {ol.Extent} */ (transformed));
|
||||
transform(transformed);
|
||||
} else {
|
||||
transformed.applyTransform(transform);
|
||||
}
|
||||
|
||||
@@ -130,7 +130,7 @@ ol.format.GML2.prototype.innerBoundaryIsParser_ = function(node, objectStack) {
|
||||
if (flatLinearRing) {
|
||||
var flatLinearRings = /** @type {Array.<Array.<number>>} */
|
||||
(objectStack[objectStack.length - 1]);
|
||||
goog.asserts.assert(goog.isArray(flatLinearRings),
|
||||
goog.asserts.assert(Array.isArray(flatLinearRings),
|
||||
'flatLinearRings should be an array');
|
||||
goog.asserts.assert(flatLinearRings.length > 0,
|
||||
'flatLinearRings should have an array length larger than 0');
|
||||
@@ -155,7 +155,7 @@ ol.format.GML2.prototype.outerBoundaryIsParser_ = function(node, objectStack) {
|
||||
if (flatLinearRing) {
|
||||
var flatLinearRings = /** @type {Array.<Array.<number>>} */
|
||||
(objectStack[objectStack.length - 1]);
|
||||
goog.asserts.assert(goog.isArray(flatLinearRings),
|
||||
goog.asserts.assert(Array.isArray(flatLinearRings),
|
||||
'flatLinearRings should be an array');
|
||||
goog.asserts.assert(flatLinearRings.length > 0,
|
||||
'flatLinearRings should have an array length larger than 0');
|
||||
|
||||
@@ -247,7 +247,7 @@ ol.format.GML3.prototype.interiorParser_ = function(node, objectStack) {
|
||||
if (flatLinearRing) {
|
||||
var flatLinearRings = /** @type {Array.<Array.<number>>} */
|
||||
(objectStack[objectStack.length - 1]);
|
||||
goog.asserts.assert(goog.isArray(flatLinearRings),
|
||||
goog.asserts.assert(Array.isArray(flatLinearRings),
|
||||
'flatLinearRings should be an array');
|
||||
goog.asserts.assert(flatLinearRings.length > 0,
|
||||
'flatLinearRings should have an array length of 1 or more');
|
||||
@@ -272,7 +272,7 @@ ol.format.GML3.prototype.exteriorParser_ = function(node, objectStack) {
|
||||
if (flatLinearRing) {
|
||||
var flatLinearRings = /** @type {Array.<Array.<number>>} */
|
||||
(objectStack[objectStack.length - 1]);
|
||||
goog.asserts.assert(goog.isArray(flatLinearRings),
|
||||
goog.asserts.assert(Array.isArray(flatLinearRings),
|
||||
'flatLinearRings should be an array');
|
||||
goog.asserts.assert(flatLinearRings.length > 0,
|
||||
'flatLinearRings should have an array length of 1 or more');
|
||||
@@ -1006,7 +1006,7 @@ ol.format.GML3.prototype.writeGeometryElement = function(node, geometry, objectS
|
||||
var item = ol.object.assign({}, context);
|
||||
item.node = node;
|
||||
var value;
|
||||
if (goog.isArray(geometry)) {
|
||||
if (Array.isArray(geometry)) {
|
||||
if (context.dataProjection) {
|
||||
value = ol.proj.transformExtent(
|
||||
geometry, context.featureProjection, context.dataProjection);
|
||||
@@ -1233,7 +1233,7 @@ ol.format.GML3.prototype.GEOMETRY_NODE_FACTORY_ = function(value, objectStack, o
|
||||
goog.asserts.assert(ol.xml.isNode(parentNode),
|
||||
'parentNode should be a node');
|
||||
var nodeName;
|
||||
if (!goog.isArray(value)) {
|
||||
if (!Array.isArray(value)) {
|
||||
goog.asserts.assertInstanceof(value, ol.geom.Geometry,
|
||||
'value should be an ol.geom.Geometry');
|
||||
nodeName = value.getType();
|
||||
|
||||
@@ -163,7 +163,7 @@ ol.format.GMLBase.prototype.readFeaturesInternal = function(node, objectStack) {
|
||||
featureNS[defaultPrefix] = ns;
|
||||
}
|
||||
var parsersNS = {};
|
||||
var featureTypes = goog.isArray(featureType) ? featureType : [featureType];
|
||||
var featureTypes = Array.isArray(featureType) ? featureType : [featureType];
|
||||
for (var p in featureNS) {
|
||||
var parsers = {};
|
||||
for (i = 0, ii = featureTypes.length; i < ii; ++i) {
|
||||
|
||||
@@ -426,7 +426,7 @@ ol.format.KML.createFeatureStyleFunction_ = function(style, styleUrl,
|
||||
* @private
|
||||
*/
|
||||
ol.format.KML.findStyle_ = function(styleValue, defaultStyle, sharedStyles) {
|
||||
if (goog.isArray(styleValue)) {
|
||||
if (Array.isArray(styleValue)) {
|
||||
return styleValue;
|
||||
} else if (typeof styleValue === 'string') {
|
||||
// KML files in the wild occasionally forget the leading `#` on styleUrls
|
||||
@@ -1267,7 +1267,7 @@ ol.format.KML.PlacemarkStyleMapParser_ = function(node, objectStack) {
|
||||
var placemarkObject = objectStack[objectStack.length - 1];
|
||||
goog.asserts.assert(goog.isObject(placemarkObject),
|
||||
'placemarkObject should be an Object');
|
||||
if (goog.isArray(styleMapValue)) {
|
||||
if (Array.isArray(styleMapValue)) {
|
||||
placemarkObject['Style'] = styleMapValue;
|
||||
} else if (typeof styleMapValue === 'string') {
|
||||
placemarkObject['styleUrl'] = styleMapValue;
|
||||
@@ -1327,7 +1327,7 @@ ol.format.KML.innerBoundaryIsParser_ = function(node, objectStack) {
|
||||
if (flatLinearRing) {
|
||||
var flatLinearRings = /** @type {Array.<Array.<number>>} */
|
||||
(objectStack[objectStack.length - 1]);
|
||||
goog.asserts.assert(goog.isArray(flatLinearRings),
|
||||
goog.asserts.assert(Array.isArray(flatLinearRings),
|
||||
'flatLinearRings should be an array');
|
||||
goog.asserts.assert(flatLinearRings.length > 0,
|
||||
'flatLinearRings array should not be empty');
|
||||
@@ -1352,7 +1352,7 @@ ol.format.KML.outerBoundaryIsParser_ = function(node, objectStack) {
|
||||
if (flatLinearRing) {
|
||||
var flatLinearRings = /** @type {Array.<Array.<number>>} */
|
||||
(objectStack[objectStack.length - 1]);
|
||||
goog.asserts.assert(goog.isArray(flatLinearRings),
|
||||
goog.asserts.assert(Array.isArray(flatLinearRings),
|
||||
'flatLinearRings should be an array');
|
||||
goog.asserts.assert(flatLinearRings.length > 0,
|
||||
'flatLinearRings array should not be empty');
|
||||
@@ -2386,7 +2386,7 @@ ol.format.KML.writePlacemark_ = function(node, feature, objectStack) {
|
||||
// resolution-independent here
|
||||
var styles = styleFunction.call(feature, 0);
|
||||
if (styles) {
|
||||
var style = goog.isArray(styles) ? styles[0] : styles;
|
||||
var style = Array.isArray(styles) ? styles[0] : styles;
|
||||
if (this.writeStyles_) {
|
||||
properties['Style'] = style;
|
||||
}
|
||||
|
||||
@@ -664,7 +664,7 @@ ol.format.WFS.prototype.writeGetFeature = function(options) {
|
||||
bbox: options.bbox,
|
||||
propertyNames: options.propertyNames ? options.propertyNames : []
|
||||
};
|
||||
goog.asserts.assert(goog.isArray(options.featureTypes),
|
||||
goog.asserts.assert(Array.isArray(options.featureTypes),
|
||||
'options.featureTypes should be an array');
|
||||
ol.format.WFS.writeGetFeature_(node, options.featureTypes, [context]);
|
||||
return node;
|
||||
|
||||
@@ -61,7 +61,7 @@ ol.layer.Group = function(opt_options) {
|
||||
this.handleLayersChanged_, this);
|
||||
|
||||
if (layers) {
|
||||
if (goog.isArray(layers)) {
|
||||
if (Array.isArray(layers)) {
|
||||
layers = new ol.Collection(layers.slice());
|
||||
} else {
|
||||
goog.asserts.assertInstanceof(layers, ol.Collection,
|
||||
|
||||
@@ -1515,7 +1515,7 @@ ol.Map.createOptionsInternal = function(options) {
|
||||
*/
|
||||
var rendererTypes;
|
||||
if (options.renderer !== undefined) {
|
||||
if (goog.isArray(options.renderer)) {
|
||||
if (Array.isArray(options.renderer)) {
|
||||
rendererTypes = options.renderer;
|
||||
} else if (typeof options.renderer === 'string') {
|
||||
rendererTypes = [options.renderer];
|
||||
@@ -1550,7 +1550,7 @@ ol.Map.createOptionsInternal = function(options) {
|
||||
|
||||
var controls;
|
||||
if (options.controls !== undefined) {
|
||||
if (goog.isArray(options.controls)) {
|
||||
if (Array.isArray(options.controls)) {
|
||||
controls = new ol.Collection(options.controls.slice());
|
||||
} else {
|
||||
goog.asserts.assertInstanceof(options.controls, ol.Collection,
|
||||
@@ -1563,7 +1563,7 @@ ol.Map.createOptionsInternal = function(options) {
|
||||
|
||||
var interactions;
|
||||
if (options.interactions !== undefined) {
|
||||
if (goog.isArray(options.interactions)) {
|
||||
if (Array.isArray(options.interactions)) {
|
||||
interactions = new ol.Collection(options.interactions.slice());
|
||||
} else {
|
||||
goog.asserts.assertInstanceof(options.interactions, ol.Collection,
|
||||
@@ -1576,7 +1576,7 @@ ol.Map.createOptionsInternal = function(options) {
|
||||
|
||||
var overlays;
|
||||
if (options.overlays !== undefined) {
|
||||
if (goog.isArray(options.overlays)) {
|
||||
if (Array.isArray(options.overlays)) {
|
||||
overlays = new ol.Collection(options.overlays.slice());
|
||||
} else {
|
||||
goog.asserts.assertInstanceof(options.overlays, ol.Collection,
|
||||
|
||||
@@ -505,7 +505,7 @@ ol.Overlay.prototype.updateRenderedPosition = function(pixel, mapSize) {
|
||||
goog.asserts.assert(mapSize !== undefined, 'mapSize should be defined');
|
||||
var style = this.element_.style;
|
||||
var offset = this.getOffset();
|
||||
goog.asserts.assert(goog.isArray(offset), 'offset should be an array');
|
||||
goog.asserts.assert(Array.isArray(offset), 'offset should be an array');
|
||||
|
||||
var positioning = this.getPositioning();
|
||||
goog.asserts.assert(positioning !== undefined,
|
||||
|
||||
@@ -328,7 +328,7 @@ ol.renderer.canvas.VectorLayer.prototype.renderFeature = function(feature, resol
|
||||
return false;
|
||||
}
|
||||
var loading = false;
|
||||
if (goog.isArray(styles)) {
|
||||
if (Array.isArray(styles)) {
|
||||
for (var i = 0, ii = styles.length; i < ii; ++i) {
|
||||
loading = ol.renderer.vector.renderFeature(
|
||||
replayGroup, feature, styles[i],
|
||||
|
||||
@@ -264,7 +264,7 @@ ol.renderer.canvas.VectorTileLayer.prototype.createReplayGroup = function(tile,
|
||||
}
|
||||
}
|
||||
if (styles) {
|
||||
if (!goog.isArray(styles)) {
|
||||
if (!Array.isArray(styles)) {
|
||||
styles = [styles];
|
||||
}
|
||||
var dirty = this.renderFeature(feature, squaredTolerance, styles,
|
||||
@@ -495,7 +495,7 @@ ol.renderer.canvas.VectorTileLayer.prototype.renderFeature = function(feature, s
|
||||
return false;
|
||||
}
|
||||
var loading = false;
|
||||
if (goog.isArray(styles)) {
|
||||
if (Array.isArray(styles)) {
|
||||
for (var i = 0, ii = styles.length; i < ii; ++i) {
|
||||
loading = ol.renderer.vector.renderFeature(
|
||||
replayGroup, feature, styles[i], squaredTolerance,
|
||||
|
||||
@@ -338,7 +338,7 @@ ol.renderer.dom.VectorLayer.prototype.renderFeature = function(feature, resoluti
|
||||
return false;
|
||||
}
|
||||
var loading = false;
|
||||
if (goog.isArray(styles)) {
|
||||
if (Array.isArray(styles)) {
|
||||
for (var i = 0, ii = styles.length; i < ii; ++i) {
|
||||
loading = ol.renderer.vector.renderFeature(
|
||||
replayGroup, feature, styles[i],
|
||||
|
||||
@@ -298,7 +298,7 @@ ol.renderer.webgl.VectorLayer.prototype.renderFeature = function(feature, resolu
|
||||
return false;
|
||||
}
|
||||
var loading = false;
|
||||
if (goog.isArray(styles)) {
|
||||
if (Array.isArray(styles)) {
|
||||
for (var i = 0, ii = styles.length; i < ii; ++i) {
|
||||
loading = ol.renderer.vector.renderFeature(
|
||||
replayGroup, feature, styles[i],
|
||||
|
||||
@@ -78,7 +78,7 @@ ol.size.scale = function(size, ratio, opt_size) {
|
||||
* @api stable
|
||||
*/
|
||||
ol.size.toSize = function(size, opt_size) {
|
||||
if (goog.isArray(size)) {
|
||||
if (Array.isArray(size)) {
|
||||
return size;
|
||||
} else {
|
||||
goog.asserts.assert(goog.isNumber(size));
|
||||
|
||||
@@ -264,7 +264,7 @@ ol.source.ImageVector.prototype.renderFeature_ = function(feature, resolution, p
|
||||
return false;
|
||||
}
|
||||
var i, ii, loading = false;
|
||||
if (!goog.isArray(styles)) {
|
||||
if (!Array.isArray(styles)) {
|
||||
styles = [styles];
|
||||
}
|
||||
for (i = 0, ii = styles.length; i < ii; ++i) {
|
||||
|
||||
@@ -172,7 +172,7 @@ ol.source.Vector = function(opt_options) {
|
||||
if (options.features instanceof ol.Collection) {
|
||||
collection = options.features;
|
||||
features = collection.getArray();
|
||||
} else if (goog.isArray(options.features)) {
|
||||
} else if (Array.isArray(options.features)) {
|
||||
features = options.features;
|
||||
}
|
||||
if (!useSpatialIndex && collection === undefined) {
|
||||
|
||||
@@ -223,7 +223,7 @@ ol.style.createStyleFunction = function(obj) {
|
||||
* @type {Array.<ol.style.Style>}
|
||||
*/
|
||||
var styles;
|
||||
if (goog.isArray(obj)) {
|
||||
if (Array.isArray(obj)) {
|
||||
styles = obj;
|
||||
} else {
|
||||
goog.asserts.assertInstanceof(obj, ol.style.Style,
|
||||
|
||||
@@ -447,7 +447,7 @@ ol.View.prototype.getZoom = function() {
|
||||
*/
|
||||
ol.View.prototype.fit = function(geometry, size, opt_options) {
|
||||
if (!(geometry instanceof ol.geom.SimpleGeometry)) {
|
||||
goog.asserts.assert(goog.isArray(geometry),
|
||||
goog.asserts.assert(Array.isArray(geometry),
|
||||
'invalid extent or geometry');
|
||||
goog.asserts.assert(!ol.extent.isEmpty(geometry),
|
||||
'cannot fit empty extent');
|
||||
|
||||
@@ -156,11 +156,11 @@ ol.xml.makeArrayExtender = function(valueReader, opt_this) {
|
||||
function(node, objectStack) {
|
||||
var value = valueReader.call(opt_this, node, objectStack);
|
||||
if (value !== undefined) {
|
||||
goog.asserts.assert(goog.isArray(value),
|
||||
goog.asserts.assert(Array.isArray(value),
|
||||
'valueReader function is expected to return an array of values');
|
||||
var array = /** @type {Array.<*>} */
|
||||
(objectStack[objectStack.length - 1]);
|
||||
goog.asserts.assert(goog.isArray(array),
|
||||
goog.asserts.assert(Array.isArray(array),
|
||||
'objectStack is supposed to be an array of arrays');
|
||||
ol.array.extend(array, value);
|
||||
}
|
||||
@@ -187,7 +187,7 @@ ol.xml.makeArrayPusher = function(valueReader, opt_this) {
|
||||
node, objectStack);
|
||||
if (value !== undefined) {
|
||||
var array = objectStack[objectStack.length - 1];
|
||||
goog.asserts.assert(goog.isArray(array),
|
||||
goog.asserts.assert(Array.isArray(array),
|
||||
'objectStack is supposed to be an array of arrays');
|
||||
array.push(value);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user