From 3c0ef430db8220beb78a360c01074e2257780f53 Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Wed, 3 Feb 2016 09:37:38 -0700 Subject: [PATCH] Use ol.object.assign() instead of goog.object.extend() --- src/ol/format/gml/gml3format.js | 5 ++--- src/ol/format/gml/gmlbaseformat.js | 3 ++- src/ol/format/wfsformat.js | 7 +++---- src/ol/format/wmsgetfeatureinfoformat.js | 4 ++-- src/ol/source/imagemapguidesource.js | 10 +++++----- src/ol/source/imagewmssource.js | 11 ++++++----- src/ol/source/tilearcgisrestsource.js | 12 +++++------- src/ol/source/tilewmssource.js | 11 ++++++----- src/ol/source/wmtssource.js | 8 ++++---- src/ol/tilegrid/tilegrid.js | 4 ++-- test/spec/ol/pointer/touchsource.test.js | 7 +++---- test_rendering/spec/ol/layer/image.test.js | 6 +++--- test_rendering/spec/ol/layer/tile.test.js | 6 +++--- test_rendering/spec/ol/layer/vectortile.test.js | 6 +++--- 14 files changed, 49 insertions(+), 51 deletions(-) diff --git a/src/ol/format/gml/gml3format.js b/src/ol/format/gml/gml3format.js index e6f548b3a1..61dbd5dd5a 100644 --- a/src/ol/format/gml/gml3format.js +++ b/src/ol/format/gml/gml3format.js @@ -3,7 +3,6 @@ goog.provide('ol.format.GML3'); goog.require('goog.asserts'); goog.require('goog.dom.NodeType'); -goog.require('goog.object'); goog.require('ol'); goog.require('ol.array'); goog.require('ol.Feature'); @@ -1270,7 +1269,7 @@ ol.format.GML3.prototype.writeGeometryNode = function(geometry, opt_options) { curve: this.curve_, surface: this.surface_, multiSurface: this.multiSurface_, multiCurve: this.multiCurve_}; if (opt_options) { - goog.object.extend(context, opt_options); + ol.object.assign(context, opt_options); } this.writeGeometryElement(geom, geometry, [context]); return geom; @@ -1313,7 +1312,7 @@ ol.format.GML3.prototype.writeFeaturesNode = function(features, opt_options) { featureType: this.featureType }; if (opt_options) { - goog.object.extend(context, opt_options); + ol.object.assign(context, opt_options); } this.writeFeatureMembers_(node, features, [context]); return node; diff --git a/src/ol/format/gml/gmlbaseformat.js b/src/ol/format/gml/gmlbaseformat.js index 55ca4c5187..4d4d7809e0 100644 --- a/src/ol/format/gml/gmlbaseformat.js +++ b/src/ol/format/gml/gmlbaseformat.js @@ -20,6 +20,7 @@ goog.require('ol.geom.MultiPoint'); goog.require('ol.geom.MultiPolygon'); goog.require('ol.geom.Point'); goog.require('ol.geom.Polygon'); +goog.require('ol.object'); goog.require('ol.proj'); goog.require('ol.xml'); @@ -607,7 +608,7 @@ ol.format.GMLBase.prototype.readFeaturesFromNode = function(node, opt_options) { featureNS: this.featureNS }; if (opt_options) { - goog.object.extend(options, this.getReadOptions(node, opt_options)); + ol.object.assign(options, this.getReadOptions(node, opt_options)); } return this.readFeaturesInternal(node, [options]); }; diff --git a/src/ol/format/wfsformat.js b/src/ol/format/wfsformat.js index a8caa61168..325e5a9bf6 100644 --- a/src/ol/format/wfsformat.js +++ b/src/ol/format/wfsformat.js @@ -2,7 +2,6 @@ goog.provide('ol.format.WFS'); goog.require('goog.asserts'); goog.require('goog.dom.NodeType'); -goog.require('goog.object'); goog.require('ol'); goog.require('ol.format.GML3'); goog.require('ol.format.GMLBase'); @@ -123,7 +122,7 @@ ol.format.WFS.prototype.readFeaturesFromNode = function(node, opt_options) { 'featureType': this.featureType_, 'featureNS': this.featureNS_ }; - goog.object.extend(context, this.getReadOptions(node, + ol.object.assign(context, this.getReadOptions(node, opt_options ? opt_options : {})); var objectStack = [context]; this.gmlFormat_.FEATURE_COLLECTION_PARSERS[ol.format.GMLBase.GMLNS][ @@ -699,7 +698,7 @@ ol.format.WFS.prototype.writeTransaction = function(inserts, updates, deletes, if (inserts) { obj = {node: node, featureNS: options.featureNS, featureType: options.featureType, featurePrefix: options.featurePrefix}; - goog.object.extend(obj, baseObj); + ol.object.assign(obj, baseObj); ol.xml.pushSerializeAndPop(obj, ol.format.WFS.TRANSACTION_SERIALIZERS_, ol.xml.makeSimpleNodeFactory('Insert'), inserts, @@ -708,7 +707,7 @@ ol.format.WFS.prototype.writeTransaction = function(inserts, updates, deletes, if (updates) { obj = {node: node, featureNS: options.featureNS, featureType: options.featureType, featurePrefix: options.featurePrefix}; - goog.object.extend(obj, baseObj); + ol.object.assign(obj, baseObj); ol.xml.pushSerializeAndPop(obj, ol.format.WFS.TRANSACTION_SERIALIZERS_, ol.xml.makeSimpleNodeFactory('Update'), updates, diff --git a/src/ol/format/wmsgetfeatureinfoformat.js b/src/ol/format/wmsgetfeatureinfoformat.js index 5f3d7c04c1..6b669742a6 100644 --- a/src/ol/format/wmsgetfeatureinfoformat.js +++ b/src/ol/format/wmsgetfeatureinfoformat.js @@ -2,10 +2,10 @@ goog.provide('ol.format.WMSGetFeatureInfo'); goog.require('goog.asserts'); goog.require('goog.dom.NodeType'); -goog.require('goog.object'); goog.require('ol.array'); goog.require('ol.format.GML2'); goog.require('ol.format.XMLFeature'); +goog.require('ol.object'); goog.require('ol.xml'); @@ -154,7 +154,7 @@ ol.format.WMSGetFeatureInfo.prototype.readFeaturesFromNode = function(node, opt_ 'featureNS': this.featureNS }; if (opt_options) { - goog.object.extend(options, this.getReadOptions(node, opt_options)); + ol.object.assign(options, this.getReadOptions(node, opt_options)); } return this.readFeatures_(node, [options]); }; diff --git a/src/ol/source/imagemapguidesource.js b/src/ol/source/imagemapguidesource.js index 270093f08d..628550a4d5 100644 --- a/src/ol/source/imagemapguidesource.js +++ b/src/ol/source/imagemapguidesource.js @@ -2,11 +2,11 @@ goog.provide('ol.source.ImageMapGuide'); goog.require('ol.events'); goog.require('ol.events.EventType'); -goog.require('goog.object'); goog.require('goog.uri.utils'); goog.require('ol.Image'); goog.require('ol.ImageLoadFunctionType'); goog.require('ol.extent'); +goog.require('ol.object'); goog.require('ol.source.Image'); @@ -43,9 +43,9 @@ ol.source.ImageMapGuide = function(options) { /** * @private - * @type {Object} + * @type {!Object} */ - this.params_ = options.params !== undefined ? options.params : {}; + this.params_ = options.params || {}; /** * @private @@ -192,7 +192,7 @@ ol.source.ImageMapGuide.getScale = function(extent, size, metersPerUnit, dpi) { * @api stable */ ol.source.ImageMapGuide.prototype.updateParams = function(params) { - goog.object.extend(this.params_, params); + ol.object.assign(this.params_, params); this.changed(); }; @@ -222,7 +222,7 @@ ol.source.ImageMapGuide.prototype.getUrl = function(baseUrl, params, extent, siz 'SETVIEWCENTERX': center[0], 'SETVIEWCENTERY': center[1] }; - goog.object.extend(baseParams, params); + ol.object.assign(baseParams, params); return goog.uri.utils.appendParamsFromMap(baseUrl, baseParams); }; diff --git a/src/ol/source/imagewmssource.js b/src/ol/source/imagewmssource.js index 211ca6d33c..9fc3d80de3 100644 --- a/src/ol/source/imagewmssource.js +++ b/src/ol/source/imagewmssource.js @@ -12,6 +12,7 @@ goog.require('ol'); goog.require('ol.Image'); goog.require('ol.ImageLoadFunctionType'); goog.require('ol.extent'); +goog.require('ol.object'); goog.require('ol.proj'); goog.require('ol.source.Image'); goog.require('ol.source.wms'); @@ -61,9 +62,9 @@ ol.source.ImageWMS = function(opt_options) { /** * @private - * @type {Object} + * @type {!Object} */ - this.params_ = options.params; + this.params_ = options.params || {}; /** * @private @@ -156,7 +157,7 @@ ol.source.ImageWMS.prototype.getGetFeatureInfoUrl = function(coordinate, resolut 'TRANSPARENT': true, 'QUERY_LAYERS': this.params_['LAYERS'] }; - goog.object.extend(baseParams, this.params_, params); + ol.object.assign(baseParams, this.params_, params); var x = Math.floor((coordinate[0] - extent[0]) / resolution); var y = Math.floor((extent[3] - coordinate[1]) / resolution); @@ -228,7 +229,7 @@ ol.source.ImageWMS.prototype.getImageInternal = function(extent, resolution, pix 'FORMAT': 'image/png', 'TRANSPARENT': true }; - goog.object.extend(params, this.params_); + ol.object.assign(params, this.params_); this.imageSize_[0] = Math.ceil(imageWidth * this.ratio_); this.imageSize_[1] = Math.ceil(imageHeight * this.ratio_); @@ -360,7 +361,7 @@ ol.source.ImageWMS.prototype.setUrl = function(url) { * @api stable */ ol.source.ImageWMS.prototype.updateParams = function(params) { - goog.object.extend(this.params_, params); + ol.object.assign(this.params_, params); this.updateV13_(); this.image_ = null; this.changed(); diff --git a/src/ol/source/tilearcgisrestsource.js b/src/ol/source/tilearcgisrestsource.js index 17ab1ff7c0..451d4d3800 100644 --- a/src/ol/source/tilearcgisrestsource.js +++ b/src/ol/source/tilearcgisrestsource.js @@ -2,12 +2,12 @@ goog.provide('ol.source.TileArcGISRest'); goog.require('goog.asserts'); goog.require('goog.math'); -goog.require('goog.object'); goog.require('goog.string'); goog.require('goog.uri.utils'); goog.require('ol'); goog.require('ol.TileCoord'); goog.require('ol.extent'); +goog.require('ol.object'); goog.require('ol.proj'); goog.require('ol.size'); goog.require('ol.source.TileImage'); @@ -32,8 +32,6 @@ ol.source.TileArcGISRest = function(opt_options) { var options = opt_options || {}; - var params = options.params !== undefined ? options.params : {}; - goog.base(this, { attributions: options.attributions, crossOrigin: options.crossOrigin, @@ -49,9 +47,9 @@ ol.source.TileArcGISRest = function(opt_options) { /** * @private - * @type {Object} + * @type {!Object} */ - this.params_ = params; + this.params_ = options.params || {}; /** * @private @@ -165,7 +163,7 @@ ol.source.TileArcGISRest.prototype.fixedTileUrlFunction = function(tileCoord, pi 'FORMAT': 'PNG32', 'TRANSPARENT': true }; - goog.object.extend(baseParams, this.params_); + ol.object.assign(baseParams, this.params_); return this.getRequestUrl_(tileCoord, tileSize, tileExtent, pixelRatio, projection, baseParams); @@ -178,6 +176,6 @@ ol.source.TileArcGISRest.prototype.fixedTileUrlFunction = function(tileCoord, pi * @api stable */ ol.source.TileArcGISRest.prototype.updateParams = function(params) { - goog.object.extend(this.params_, params); + ol.object.assign(this.params_, params); this.changed(); }; diff --git a/src/ol/source/tilewmssource.js b/src/ol/source/tilewmssource.js index 48fb3b3c44..4ba0730b2d 100644 --- a/src/ol/source/tilewmssource.js +++ b/src/ol/source/tilewmssource.js @@ -12,6 +12,7 @@ goog.require('goog.uri.utils'); goog.require('ol'); goog.require('ol.TileCoord'); goog.require('ol.extent'); +goog.require('ol.object'); goog.require('ol.proj'); goog.require('ol.size'); goog.require('ol.source.TileImage'); @@ -33,7 +34,7 @@ ol.source.TileWMS = function(opt_options) { var options = opt_options || {}; - var params = options.params !== undefined ? options.params : {}; + var params = options.params || {}; var transparent = goog.object.get(params, 'TRANSPARENT', true); @@ -59,7 +60,7 @@ ol.source.TileWMS = function(opt_options) { /** * @private - * @type {Object} + * @type {!Object} */ this.params_ = params; @@ -161,7 +162,7 @@ ol.source.TileWMS.prototype.getGetFeatureInfoUrl = function(coordinate, resoluti 'TRANSPARENT': true, 'QUERY_LAYERS': this.params_['LAYERS'] }; - goog.object.extend(baseParams, this.params_, params); + ol.object.assign(baseParams, this.params_, params); var x = Math.floor((coordinate[0] - tileExtent[0]) / tileResolution); var y = Math.floor((tileExtent[3] - coordinate[1]) / tileResolution); @@ -363,7 +364,7 @@ ol.source.TileWMS.prototype.fixedTileUrlFunction = function(tileCoord, pixelRati 'FORMAT': 'image/png', 'TRANSPARENT': true }; - goog.object.extend(baseParams, this.params_); + ol.object.assign(baseParams, this.params_); return this.getRequestUrl_(tileCoord, tileSize, tileExtent, pixelRatio, projection, baseParams); @@ -376,7 +377,7 @@ ol.source.TileWMS.prototype.fixedTileUrlFunction = function(tileCoord, pixelRati * @api stable */ ol.source.TileWMS.prototype.updateParams = function(params) { - goog.object.extend(this.params_, params); + ol.object.assign(this.params_, params); this.resetCoordKeyPrefix_(); this.resetParamsKey_(); this.updateV13_(); diff --git a/src/ol/source/wmtssource.js b/src/ol/source/wmtssource.js index 8284404296..8b4ecdce35 100644 --- a/src/ol/source/wmtssource.js +++ b/src/ol/source/wmtssource.js @@ -2,12 +2,12 @@ goog.provide('ol.source.WMTS'); goog.provide('ol.source.WMTSRequestEncoding'); goog.require('goog.asserts'); -goog.require('goog.object'); goog.require('goog.uri.utils'); goog.require('ol.TileUrlFunction'); goog.require('ol.TileUrlFunctionType'); goog.require('ol.array'); goog.require('ol.extent'); +goog.require('ol.object'); goog.require('ol.proj'); goog.require('ol.source.TileImage'); goog.require('ol.tilegrid.WMTS'); @@ -111,7 +111,7 @@ ol.source.WMTS = function(options) { }; if (requestEncoding == ol.source.WMTSRequestEncoding.KVP) { - goog.object.extend(context, { + ol.object.assign(context, { 'Service': 'WMTS', 'Request': 'GetTile', 'Version': this.version_, @@ -153,7 +153,7 @@ ol.source.WMTS = function(options) { 'TileCol': tileCoord[1], 'TileRow': -tileCoord[2] - 1 }; - goog.object.extend(localContext, dimensions); + ol.object.assign(localContext, dimensions); var url = template; if (requestEncoding == ol.source.WMTSRequestEncoding.KVP) { url = goog.uri.utils.appendParamsFromMap(url, localContext); @@ -290,7 +290,7 @@ ol.source.WMTS.prototype.resetDimensionsKey_ = function() { * @api */ ol.source.WMTS.prototype.updateDimensions = function(dimensions) { - goog.object.extend(this.dimensions_, dimensions); + ol.object.assign(this.dimensions_, dimensions); this.resetDimensionsKey_(); this.changed(); }; diff --git a/src/ol/tilegrid/tilegrid.js b/src/ol/tilegrid/tilegrid.js index 41ebf2d3c2..589b1178f4 100644 --- a/src/ol/tilegrid/tilegrid.js +++ b/src/ol/tilegrid/tilegrid.js @@ -1,7 +1,6 @@ goog.provide('ol.tilegrid.TileGrid'); goog.require('goog.asserts'); -goog.require('goog.object'); goog.require('ol'); goog.require('ol.Coordinate'); goog.require('ol.TileCoord'); @@ -10,6 +9,7 @@ goog.require('ol.array'); goog.require('ol.extent'); goog.require('ol.extent.Corner'); goog.require('ol.math'); +goog.require('ol.object'); goog.require('ol.proj'); goog.require('ol.proj.METERS_PER_UNIT'); goog.require('ol.proj.Projection'); @@ -542,7 +542,7 @@ ol.tilegrid.createForExtent = function(extent, opt_maxZoom, opt_tileSize, opt_co */ ol.tilegrid.createXYZ = function(opt_options) { var options = /** @type {olx.tilegrid.TileGridOptions} */ ({}); - goog.object.extend(options, opt_options !== undefined ? + ol.object.assign(options, opt_options !== undefined ? opt_options : /** @type {olx.tilegrid.XYZOptions} */ ({})); if (options.extent === undefined) { options.extent = ol.proj.get('EPSG:3857').getExtent(); diff --git a/test/spec/ol/pointer/touchsource.test.js b/test/spec/ol/pointer/touchsource.test.js index 304ec45a91..dba05424bc 100644 --- a/test/spec/ol/pointer/touchsource.test.js +++ b/test/spec/ol/pointer/touchsource.test.js @@ -1,7 +1,5 @@ goog.provide('ol.test.pointer.TouchSource'); -goog.require('goog.object'); - describe('ol.pointer.TouchSource', function() { var handler; var target; @@ -121,7 +119,7 @@ describe('ol.pointer.TouchSource', function() { touches = touches !== undefined ? touches : changedTouches; var event = new ol.events.Event(type); - goog.object.extend(event, { + ol.object.assign(event, { touches: touches, changedTouches: changedTouches }); @@ -129,11 +127,12 @@ describe('ol.pointer.TouchSource', function() { } }); -goog.require('goog.dom'); +goog.require('goog.object'); goog.require('ol.events'); goog.require('ol.events.Event'); goog.require('ol.events.EventTarget'); goog.require('ol.has'); +goog.require('ol.object'); goog.require('ol.pointer.PointerEvent'); goog.require('ol.pointer.PointerEventHandler'); goog.require('ol.pointer.TouchSource'); diff --git a/test_rendering/spec/ol/layer/image.test.js b/test_rendering/spec/ol/layer/image.test.js index 18166be2b6..079c956a52 100644 --- a/test_rendering/spec/ol/layer/image.test.js +++ b/test_rendering/spec/ol/layer/image.test.js @@ -44,7 +44,7 @@ describe('ol.rendering.layer.Image', function() { var options = { source: source }; - goog.object.extend(options, layerOptions); + ol.object.assign(options, layerOptions); map.addLayer(new ol.layer.Image(options)); }); } @@ -109,9 +109,9 @@ describe('ol.rendering.layer.Image', function() { }); -goog.require('goog.object'); -goog.require('ol.proj'); goog.require('ol.Map'); goog.require('ol.View'); goog.require('ol.layer.Image'); +goog.require('ol.object'); +goog.require('ol.proj'); goog.require('ol.source.ImageStatic'); diff --git a/test_rendering/spec/ol/layer/tile.test.js b/test_rendering/spec/ol/layer/tile.test.js index 310621d708..d41d6cf560 100644 --- a/test_rendering/spec/ol/layer/tile.test.js +++ b/test_rendering/spec/ol/layer/tile.test.js @@ -44,7 +44,7 @@ describe('ol.rendering.layer.Tile', function() { var options = { source: source }; - goog.object.extend(options, layerOptions); + ol.object.assign(options, layerOptions); map.addLayer(new ol.layer.Tile(options)); }); } @@ -190,11 +190,11 @@ describe('ol.rendering.layer.Tile', function() { }); -goog.require('goog.object'); -goog.require('ol.proj'); goog.require('ol.Map'); goog.require('ol.View'); goog.require('ol.layer.Tile'); +goog.require('ol.object'); +goog.require('ol.proj'); goog.require('ol.source.TileImage'); goog.require('ol.source.XYZ'); goog.require('ol.tilegrid.TileGrid'); diff --git a/test_rendering/spec/ol/layer/vectortile.test.js b/test_rendering/spec/ol/layer/vectortile.test.js index 9beddd4a22..86dc75e7fb 100644 --- a/test_rendering/spec/ol/layer/vectortile.test.js +++ b/test_rendering/spec/ol/layer/vectortile.test.js @@ -42,7 +42,7 @@ describe('ol.rendering.layer.VectorTile', function() { var options = { source: source }; - goog.object.extend(options, layerOptions); + ol.object.assign(options, layerOptions); map.addLayer(new ol.layer.VectorTile(options)); } @@ -74,9 +74,9 @@ describe('ol.rendering.layer.VectorTile', function() { }); -goog.require('goog.object'); -goog.require('ol.format.MVT'); goog.require('ol.Map'); goog.require('ol.View'); +goog.require('ol.format.MVT'); goog.require('ol.layer.VectorTile'); +goog.require('ol.object'); goog.require('ol.source.VectorTile');