Use ol.object.assign() instead of goog.object.extend()

This commit is contained in:
Tim Schaub
2016-02-03 09:37:38 -07:00
parent a74af66d5f
commit 3c0ef430db
14 changed files with 49 additions and 51 deletions

View File

@@ -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;

View File

@@ -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]);
};

View File

@@ -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,

View File

@@ -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]);
};

View File

@@ -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);
};

View File

@@ -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();

View File

@@ -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();
};

View File

@@ -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_();

View File

@@ -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();
};

View File

@@ -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();

View File

@@ -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');

View File

@@ -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');

View File

@@ -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');

View File

@@ -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');