Merge pull request #4804 from fredj/rm_goog.isArray

Use Array.isArray instead of goog.isArray
This commit is contained in:
Frédéric Junod
2016-04-04 09:25:41 +02:00
23 changed files with 39 additions and 39 deletions

View File

@@ -169,7 +169,7 @@ ol.array.reverseSubArray = function(arr, begin, end) {
*/ */
ol.array.flatten = function(arr) { ol.array.flatten = function(arr) {
var data = arr.reduce(function(flattened, value) { var data = arr.reduce(function(flattened, value) {
if (goog.isArray(value)) { if (Array.isArray(value)) {
return flattened.concat(ol.array.flatten(value)); return flattened.concat(ol.array.flatten(value));
} else { } else {
return flattened.concat(value); return flattened.concat(value);

View File

@@ -61,7 +61,7 @@ ol.color.rgbaColorRe_ =
* @api * @api
*/ */
ol.color.asArray = function(color) { ol.color.asArray = function(color) {
if (goog.isArray(color)) { if (Array.isArray(color)) {
return color; return color;
} else { } else {
goog.asserts.assert(typeof color === 'string', 'Color should be a string'); goog.asserts.assert(typeof color === 'string', 'Color should be a string');
@@ -80,7 +80,7 @@ ol.color.asString = function(color) {
if (typeof color === 'string') { if (typeof color === 'string') {
return color; return color;
} else { } 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); return ol.color.toString(color);
} }
}; };

View File

@@ -314,7 +314,7 @@ ol.Feature.createStyleFunction = function(obj) {
* @type {Array.<ol.style.Style>} * @type {Array.<ol.style.Style>}
*/ */
var styles; var styles;
if (goog.isArray(obj)) { if (Array.isArray(obj)) {
styles = obj; styles = obj;
} else { } else {
goog.asserts.assertInstanceof(obj, ol.style.Style, goog.asserts.assertInstanceof(obj, ol.style.Style,

View File

@@ -170,7 +170,7 @@ ol.format.EsriJSON.readPointGeometry_ = function(object) {
* @return {ol.geom.Geometry} LineString. * @return {ol.geom.Geometry} LineString.
*/ */
ol.format.EsriJSON.readLineStringGeometry_ = function(object) { 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'); 'object.paths should be an array');
goog.asserts.assert(object.paths.length === 1, goog.asserts.assert(object.paths.length === 1,
'object.paths array length should be 1'); 'object.paths array length should be 1');
@@ -185,7 +185,7 @@ ol.format.EsriJSON.readLineStringGeometry_ = function(object) {
* @return {ol.geom.Geometry} MultiLineString. * @return {ol.geom.Geometry} MultiLineString.
*/ */
ol.format.EsriJSON.readMultiLineStringGeometry_ = function(object) { 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'); 'object.paths should be an array');
goog.asserts.assert(object.paths.length > 1, goog.asserts.assert(object.paths.length > 1,
'object.paths array length should be more than 1'); 'object.paths array length should be more than 1');

View File

@@ -203,7 +203,7 @@ ol.format.Feature.transformWithOptions = function(
return coordinates; return coordinates;
}; };
if (Array.isArray(transformed)) { if (Array.isArray(transformed)) {
transform(/** @type {ol.Extent} */ (transformed)); transform(transformed);
} else { } else {
transformed.applyTransform(transform); transformed.applyTransform(transform);
} }

View File

@@ -130,7 +130,7 @@ ol.format.GML2.prototype.innerBoundaryIsParser_ = function(node, objectStack) {
if (flatLinearRing) { if (flatLinearRing) {
var flatLinearRings = /** @type {Array.<Array.<number>>} */ var flatLinearRings = /** @type {Array.<Array.<number>>} */
(objectStack[objectStack.length - 1]); (objectStack[objectStack.length - 1]);
goog.asserts.assert(goog.isArray(flatLinearRings), goog.asserts.assert(Array.isArray(flatLinearRings),
'flatLinearRings should be an array'); 'flatLinearRings should be an array');
goog.asserts.assert(flatLinearRings.length > 0, goog.asserts.assert(flatLinearRings.length > 0,
'flatLinearRings should have an array length larger than 0'); 'flatLinearRings should have an array length larger than 0');
@@ -155,7 +155,7 @@ ol.format.GML2.prototype.outerBoundaryIsParser_ = function(node, objectStack) {
if (flatLinearRing) { if (flatLinearRing) {
var flatLinearRings = /** @type {Array.<Array.<number>>} */ var flatLinearRings = /** @type {Array.<Array.<number>>} */
(objectStack[objectStack.length - 1]); (objectStack[objectStack.length - 1]);
goog.asserts.assert(goog.isArray(flatLinearRings), goog.asserts.assert(Array.isArray(flatLinearRings),
'flatLinearRings should be an array'); 'flatLinearRings should be an array');
goog.asserts.assert(flatLinearRings.length > 0, goog.asserts.assert(flatLinearRings.length > 0,
'flatLinearRings should have an array length larger than 0'); 'flatLinearRings should have an array length larger than 0');

View File

@@ -247,7 +247,7 @@ ol.format.GML3.prototype.interiorParser_ = function(node, objectStack) {
if (flatLinearRing) { if (flatLinearRing) {
var flatLinearRings = /** @type {Array.<Array.<number>>} */ var flatLinearRings = /** @type {Array.<Array.<number>>} */
(objectStack[objectStack.length - 1]); (objectStack[objectStack.length - 1]);
goog.asserts.assert(goog.isArray(flatLinearRings), goog.asserts.assert(Array.isArray(flatLinearRings),
'flatLinearRings should be an array'); 'flatLinearRings should be an array');
goog.asserts.assert(flatLinearRings.length > 0, goog.asserts.assert(flatLinearRings.length > 0,
'flatLinearRings should have an array length of 1 or more'); 'flatLinearRings should have an array length of 1 or more');
@@ -272,7 +272,7 @@ ol.format.GML3.prototype.exteriorParser_ = function(node, objectStack) {
if (flatLinearRing) { if (flatLinearRing) {
var flatLinearRings = /** @type {Array.<Array.<number>>} */ var flatLinearRings = /** @type {Array.<Array.<number>>} */
(objectStack[objectStack.length - 1]); (objectStack[objectStack.length - 1]);
goog.asserts.assert(goog.isArray(flatLinearRings), goog.asserts.assert(Array.isArray(flatLinearRings),
'flatLinearRings should be an array'); 'flatLinearRings should be an array');
goog.asserts.assert(flatLinearRings.length > 0, goog.asserts.assert(flatLinearRings.length > 0,
'flatLinearRings should have an array length of 1 or more'); '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); var item = ol.object.assign({}, context);
item.node = node; item.node = node;
var value; var value;
if (goog.isArray(geometry)) { if (Array.isArray(geometry)) {
if (context.dataProjection) { if (context.dataProjection) {
value = ol.proj.transformExtent( value = ol.proj.transformExtent(
geometry, context.featureProjection, context.dataProjection); 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), goog.asserts.assert(ol.xml.isNode(parentNode),
'parentNode should be a node'); 'parentNode should be a node');
var nodeName; var nodeName;
if (!goog.isArray(value)) { if (!Array.isArray(value)) {
goog.asserts.assertInstanceof(value, ol.geom.Geometry, goog.asserts.assertInstanceof(value, ol.geom.Geometry,
'value should be an ol.geom.Geometry'); 'value should be an ol.geom.Geometry');
nodeName = value.getType(); nodeName = value.getType();

View File

@@ -163,7 +163,7 @@ ol.format.GMLBase.prototype.readFeaturesInternal = function(node, objectStack) {
featureNS[defaultPrefix] = ns; featureNS[defaultPrefix] = ns;
} }
var parsersNS = {}; var parsersNS = {};
var featureTypes = goog.isArray(featureType) ? featureType : [featureType]; var featureTypes = Array.isArray(featureType) ? featureType : [featureType];
for (var p in featureNS) { for (var p in featureNS) {
var parsers = {}; var parsers = {};
for (i = 0, ii = featureTypes.length; i < ii; ++i) { for (i = 0, ii = featureTypes.length; i < ii; ++i) {

View File

@@ -426,7 +426,7 @@ ol.format.KML.createFeatureStyleFunction_ = function(style, styleUrl,
* @private * @private
*/ */
ol.format.KML.findStyle_ = function(styleValue, defaultStyle, sharedStyles) { ol.format.KML.findStyle_ = function(styleValue, defaultStyle, sharedStyles) {
if (goog.isArray(styleValue)) { if (Array.isArray(styleValue)) {
return styleValue; return styleValue;
} else if (typeof styleValue === 'string') { } else if (typeof styleValue === 'string') {
// KML files in the wild occasionally forget the leading `#` on styleUrls // 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]; var placemarkObject = objectStack[objectStack.length - 1];
goog.asserts.assert(goog.isObject(placemarkObject), goog.asserts.assert(goog.isObject(placemarkObject),
'placemarkObject should be an Object'); 'placemarkObject should be an Object');
if (goog.isArray(styleMapValue)) { if (Array.isArray(styleMapValue)) {
placemarkObject['Style'] = styleMapValue; placemarkObject['Style'] = styleMapValue;
} else if (typeof styleMapValue === 'string') { } else if (typeof styleMapValue === 'string') {
placemarkObject['styleUrl'] = styleMapValue; placemarkObject['styleUrl'] = styleMapValue;
@@ -1327,7 +1327,7 @@ ol.format.KML.innerBoundaryIsParser_ = function(node, objectStack) {
if (flatLinearRing) { if (flatLinearRing) {
var flatLinearRings = /** @type {Array.<Array.<number>>} */ var flatLinearRings = /** @type {Array.<Array.<number>>} */
(objectStack[objectStack.length - 1]); (objectStack[objectStack.length - 1]);
goog.asserts.assert(goog.isArray(flatLinearRings), goog.asserts.assert(Array.isArray(flatLinearRings),
'flatLinearRings should be an array'); 'flatLinearRings should be an array');
goog.asserts.assert(flatLinearRings.length > 0, goog.asserts.assert(flatLinearRings.length > 0,
'flatLinearRings array should not be empty'); 'flatLinearRings array should not be empty');
@@ -1352,7 +1352,7 @@ ol.format.KML.outerBoundaryIsParser_ = function(node, objectStack) {
if (flatLinearRing) { if (flatLinearRing) {
var flatLinearRings = /** @type {Array.<Array.<number>>} */ var flatLinearRings = /** @type {Array.<Array.<number>>} */
(objectStack[objectStack.length - 1]); (objectStack[objectStack.length - 1]);
goog.asserts.assert(goog.isArray(flatLinearRings), goog.asserts.assert(Array.isArray(flatLinearRings),
'flatLinearRings should be an array'); 'flatLinearRings should be an array');
goog.asserts.assert(flatLinearRings.length > 0, goog.asserts.assert(flatLinearRings.length > 0,
'flatLinearRings array should not be empty'); 'flatLinearRings array should not be empty');
@@ -2386,7 +2386,7 @@ ol.format.KML.writePlacemark_ = function(node, feature, objectStack) {
// resolution-independent here // resolution-independent here
var styles = styleFunction.call(feature, 0); var styles = styleFunction.call(feature, 0);
if (styles) { if (styles) {
var style = goog.isArray(styles) ? styles[0] : styles; var style = Array.isArray(styles) ? styles[0] : styles;
if (this.writeStyles_) { if (this.writeStyles_) {
properties['Style'] = style; properties['Style'] = style;
} }

View File

@@ -664,7 +664,7 @@ ol.format.WFS.prototype.writeGetFeature = function(options) {
bbox: options.bbox, bbox: options.bbox,
propertyNames: options.propertyNames ? options.propertyNames : [] 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'); 'options.featureTypes should be an array');
ol.format.WFS.writeGetFeature_(node, options.featureTypes, [context]); ol.format.WFS.writeGetFeature_(node, options.featureTypes, [context]);
return node; return node;

View File

@@ -61,7 +61,7 @@ ol.layer.Group = function(opt_options) {
this.handleLayersChanged_, this); this.handleLayersChanged_, this);
if (layers) { if (layers) {
if (goog.isArray(layers)) { if (Array.isArray(layers)) {
layers = new ol.Collection(layers.slice()); layers = new ol.Collection(layers.slice());
} else { } else {
goog.asserts.assertInstanceof(layers, ol.Collection, goog.asserts.assertInstanceof(layers, ol.Collection,

View File

@@ -1515,7 +1515,7 @@ ol.Map.createOptionsInternal = function(options) {
*/ */
var rendererTypes; var rendererTypes;
if (options.renderer !== undefined) { if (options.renderer !== undefined) {
if (goog.isArray(options.renderer)) { if (Array.isArray(options.renderer)) {
rendererTypes = options.renderer; rendererTypes = options.renderer;
} else if (typeof options.renderer === 'string') { } else if (typeof options.renderer === 'string') {
rendererTypes = [options.renderer]; rendererTypes = [options.renderer];
@@ -1550,7 +1550,7 @@ ol.Map.createOptionsInternal = function(options) {
var controls; var controls;
if (options.controls !== undefined) { if (options.controls !== undefined) {
if (goog.isArray(options.controls)) { if (Array.isArray(options.controls)) {
controls = new ol.Collection(options.controls.slice()); controls = new ol.Collection(options.controls.slice());
} else { } else {
goog.asserts.assertInstanceof(options.controls, ol.Collection, goog.asserts.assertInstanceof(options.controls, ol.Collection,
@@ -1563,7 +1563,7 @@ ol.Map.createOptionsInternal = function(options) {
var interactions; var interactions;
if (options.interactions !== undefined) { if (options.interactions !== undefined) {
if (goog.isArray(options.interactions)) { if (Array.isArray(options.interactions)) {
interactions = new ol.Collection(options.interactions.slice()); interactions = new ol.Collection(options.interactions.slice());
} else { } else {
goog.asserts.assertInstanceof(options.interactions, ol.Collection, goog.asserts.assertInstanceof(options.interactions, ol.Collection,
@@ -1576,7 +1576,7 @@ ol.Map.createOptionsInternal = function(options) {
var overlays; var overlays;
if (options.overlays !== undefined) { if (options.overlays !== undefined) {
if (goog.isArray(options.overlays)) { if (Array.isArray(options.overlays)) {
overlays = new ol.Collection(options.overlays.slice()); overlays = new ol.Collection(options.overlays.slice());
} else { } else {
goog.asserts.assertInstanceof(options.overlays, ol.Collection, goog.asserts.assertInstanceof(options.overlays, ol.Collection,

View File

@@ -505,7 +505,7 @@ ol.Overlay.prototype.updateRenderedPosition = function(pixel, mapSize) {
goog.asserts.assert(mapSize !== undefined, 'mapSize should be defined'); goog.asserts.assert(mapSize !== undefined, 'mapSize should be defined');
var style = this.element_.style; var style = this.element_.style;
var offset = this.getOffset(); 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(); var positioning = this.getPositioning();
goog.asserts.assert(positioning !== undefined, goog.asserts.assert(positioning !== undefined,

View File

@@ -328,7 +328,7 @@ ol.renderer.canvas.VectorLayer.prototype.renderFeature = function(feature, resol
return false; return false;
} }
var loading = false; var loading = false;
if (goog.isArray(styles)) { if (Array.isArray(styles)) {
for (var i = 0, ii = styles.length; i < ii; ++i) { for (var i = 0, ii = styles.length; i < ii; ++i) {
loading = ol.renderer.vector.renderFeature( loading = ol.renderer.vector.renderFeature(
replayGroup, feature, styles[i], replayGroup, feature, styles[i],

View File

@@ -264,7 +264,7 @@ ol.renderer.canvas.VectorTileLayer.prototype.createReplayGroup = function(tile,
} }
} }
if (styles) { if (styles) {
if (!goog.isArray(styles)) { if (!Array.isArray(styles)) {
styles = [styles]; styles = [styles];
} }
var dirty = this.renderFeature(feature, squaredTolerance, styles, var dirty = this.renderFeature(feature, squaredTolerance, styles,
@@ -495,7 +495,7 @@ ol.renderer.canvas.VectorTileLayer.prototype.renderFeature = function(feature, s
return false; return false;
} }
var loading = false; var loading = false;
if (goog.isArray(styles)) { if (Array.isArray(styles)) {
for (var i = 0, ii = styles.length; i < ii; ++i) { for (var i = 0, ii = styles.length; i < ii; ++i) {
loading = ol.renderer.vector.renderFeature( loading = ol.renderer.vector.renderFeature(
replayGroup, feature, styles[i], squaredTolerance, replayGroup, feature, styles[i], squaredTolerance,

View File

@@ -338,7 +338,7 @@ ol.renderer.dom.VectorLayer.prototype.renderFeature = function(feature, resoluti
return false; return false;
} }
var loading = false; var loading = false;
if (goog.isArray(styles)) { if (Array.isArray(styles)) {
for (var i = 0, ii = styles.length; i < ii; ++i) { for (var i = 0, ii = styles.length; i < ii; ++i) {
loading = ol.renderer.vector.renderFeature( loading = ol.renderer.vector.renderFeature(
replayGroup, feature, styles[i], replayGroup, feature, styles[i],

View File

@@ -298,7 +298,7 @@ ol.renderer.webgl.VectorLayer.prototype.renderFeature = function(feature, resolu
return false; return false;
} }
var loading = false; var loading = false;
if (goog.isArray(styles)) { if (Array.isArray(styles)) {
for (var i = 0, ii = styles.length; i < ii; ++i) { for (var i = 0, ii = styles.length; i < ii; ++i) {
loading = ol.renderer.vector.renderFeature( loading = ol.renderer.vector.renderFeature(
replayGroup, feature, styles[i], replayGroup, feature, styles[i],

View File

@@ -78,7 +78,7 @@ ol.size.scale = function(size, ratio, opt_size) {
* @api stable * @api stable
*/ */
ol.size.toSize = function(size, opt_size) { ol.size.toSize = function(size, opt_size) {
if (goog.isArray(size)) { if (Array.isArray(size)) {
return size; return size;
} else { } else {
goog.asserts.assert(goog.isNumber(size)); goog.asserts.assert(goog.isNumber(size));

View File

@@ -264,7 +264,7 @@ ol.source.ImageVector.prototype.renderFeature_ = function(feature, resolution, p
return false; return false;
} }
var i, ii, loading = false; var i, ii, loading = false;
if (!goog.isArray(styles)) { if (!Array.isArray(styles)) {
styles = [styles]; styles = [styles];
} }
for (i = 0, ii = styles.length; i < ii; ++i) { for (i = 0, ii = styles.length; i < ii; ++i) {

View File

@@ -172,7 +172,7 @@ ol.source.Vector = function(opt_options) {
if (options.features instanceof ol.Collection) { if (options.features instanceof ol.Collection) {
collection = options.features; collection = options.features;
features = collection.getArray(); features = collection.getArray();
} else if (goog.isArray(options.features)) { } else if (Array.isArray(options.features)) {
features = options.features; features = options.features;
} }
if (!useSpatialIndex && collection === undefined) { if (!useSpatialIndex && collection === undefined) {

View File

@@ -223,7 +223,7 @@ ol.style.createStyleFunction = function(obj) {
* @type {Array.<ol.style.Style>} * @type {Array.<ol.style.Style>}
*/ */
var styles; var styles;
if (goog.isArray(obj)) { if (Array.isArray(obj)) {
styles = obj; styles = obj;
} else { } else {
goog.asserts.assertInstanceof(obj, ol.style.Style, goog.asserts.assertInstanceof(obj, ol.style.Style,

View File

@@ -447,7 +447,7 @@ ol.View.prototype.getZoom = function() {
*/ */
ol.View.prototype.fit = function(geometry, size, opt_options) { ol.View.prototype.fit = function(geometry, size, opt_options) {
if (!(geometry instanceof ol.geom.SimpleGeometry)) { if (!(geometry instanceof ol.geom.SimpleGeometry)) {
goog.asserts.assert(goog.isArray(geometry), goog.asserts.assert(Array.isArray(geometry),
'invalid extent or geometry'); 'invalid extent or geometry');
goog.asserts.assert(!ol.extent.isEmpty(geometry), goog.asserts.assert(!ol.extent.isEmpty(geometry),
'cannot fit empty extent'); 'cannot fit empty extent');

View File

@@ -156,11 +156,11 @@ ol.xml.makeArrayExtender = function(valueReader, opt_this) {
function(node, objectStack) { function(node, objectStack) {
var value = valueReader.call(opt_this, node, objectStack); var value = valueReader.call(opt_this, node, objectStack);
if (value !== undefined) { 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'); 'valueReader function is expected to return an array of values');
var array = /** @type {Array.<*>} */ var array = /** @type {Array.<*>} */
(objectStack[objectStack.length - 1]); (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'); 'objectStack is supposed to be an array of arrays');
ol.array.extend(array, value); ol.array.extend(array, value);
} }
@@ -187,7 +187,7 @@ ol.xml.makeArrayPusher = function(valueReader, opt_this) {
node, objectStack); node, objectStack);
if (value !== undefined) { if (value !== undefined) {
var array = objectStack[objectStack.length - 1]; 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'); 'objectStack is supposed to be an array of arrays');
array.push(value); array.push(value);
} }