From 25d47ed7526459ea58ec4de3786aae3a82e5fac7 Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Wed, 27 Jul 2022 14:22:04 -0600 Subject: [PATCH] Use Object.assign --- package-lock.json | 14 ++++---- package.json | 2 +- src/ol/Map.js | 3 +- src/ol/Object.js | 6 ++-- src/ol/View.js | 11 +++--- src/ol/format/EsriJSON.js | 6 ++-- src/ol/format/Feature.js | 3 +- src/ol/format/GML2.js | 5 ++- src/ol/format/GML3.js | 11 +++--- src/ol/format/GMLBase.js | 3 +- src/ol/format/GeoJSON.js | 4 +-- src/ol/format/WFS.js | 28 ++++++++------- src/ol/format/WKB.js | 5 ++- src/ol/format/WMSGetFeatureInfo.js | 3 +- src/ol/interaction/Link.js | 5 ++- src/ol/layer/Base.js | 5 ++- src/ol/layer/BaseTile.js | 3 +- src/ol/layer/BaseVector.js | 3 +- src/ol/layer/Graticule.js | 3 +- src/ol/layer/Group.js | 4 +-- src/ol/layer/Heatmap.js | 3 +- src/ol/layer/Layer.js | 3 +- src/ol/layer/VectorImage.js | 3 +- src/ol/layer/VectorTile.js | 3 +- src/ol/layer/WebGLPoints.js | 5 ++- src/ol/layer/WebGLTile.js | 5 ++- src/ol/obj.js | 31 ----------------- src/ol/renderer/canvas/ImageLayer.js | 5 ++- src/ol/renderer/canvas/TileLayer.js | 5 ++- src/ol/renderer/canvas/VectorImageLayer.js | 7 ++-- src/ol/reproj.js | 5 ++- src/ol/source/CartoDB.js | 3 +- src/ol/source/DataTile.js | 3 +- src/ol/source/ImageArcGISRest.js | 5 ++- src/ol/source/ImageMapGuide.js | 5 ++- src/ol/source/ImageStatic.js | 3 +- src/ol/source/ImageWMS.js | 9 +++-- src/ol/source/Raster.js | 5 ++- src/ol/source/TileArcGISRest.js | 5 ++- src/ol/source/TileWMS.js | 9 +++-- src/ol/source/WMTS.js | 7 ++-- src/ol/source/ogcTileUtil.js | 3 +- src/ol/webgl.js | 3 +- src/ol/worker/webgl.js | 7 ++-- test/browser/spec/ol/layer/Group.test.js | 11 +++--- test/node/ol/obj.test.js | 40 +--------------------- 46 files changed, 108 insertions(+), 212 deletions(-) diff --git a/package-lock.json b/package-lock.json index 0efc6314bd..de32cf32f7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,7 +11,7 @@ "dependencies": { "earcut": "^2.2.3", "geotiff": "2.0.4", - "ol-mapbox-style": "8.2.0", + "ol-mapbox-style": "8.2.1", "pbf": "3.2.1", "rbush": "^3.0.1" }, @@ -7353,9 +7353,9 @@ "dev": true }, "node_modules/ol-mapbox-style": { - "version": "8.2.0", - "resolved": "https://registry.npmjs.org/ol-mapbox-style/-/ol-mapbox-style-8.2.0.tgz", - "integrity": "sha512-WyCiNUj5DiD3+MvgqXvxSf0mDUvagtlq9JQ97mHwDD1FliHt5G1333Lvqskg8psBfxijHSEWNHwqzBGnEUo1bw==", + "version": "8.2.1", + "resolved": "https://registry.npmjs.org/ol-mapbox-style/-/ol-mapbox-style-8.2.1.tgz", + "integrity": "sha512-3kBBuZC627vDL8vnUdfVbCbfkhkcZj2kXPHQcuLhC4JJEA+XkEVEtEde8x8+AZctRbHwBkSiubTPaRukgLxIRw==", "dependencies": { "@mapbox/mapbox-gl-style-spec": "^13.23.1", "mapbox-to-css-font": "^2.4.1" @@ -15844,9 +15844,9 @@ "dev": true }, "ol-mapbox-style": { - "version": "8.2.0", - "resolved": "https://registry.npmjs.org/ol-mapbox-style/-/ol-mapbox-style-8.2.0.tgz", - "integrity": "sha512-WyCiNUj5DiD3+MvgqXvxSf0mDUvagtlq9JQ97mHwDD1FliHt5G1333Lvqskg8psBfxijHSEWNHwqzBGnEUo1bw==", + "version": "8.2.1", + "resolved": "https://registry.npmjs.org/ol-mapbox-style/-/ol-mapbox-style-8.2.1.tgz", + "integrity": "sha512-3kBBuZC627vDL8vnUdfVbCbfkhkcZj2kXPHQcuLhC4JJEA+XkEVEtEde8x8+AZctRbHwBkSiubTPaRukgLxIRw==", "requires": { "@mapbox/mapbox-gl-style-spec": "^13.23.1", "mapbox-to-css-font": "^2.4.1" diff --git a/package.json b/package.json index d60b60d04c..5c12c1b337 100644 --- a/package.json +++ b/package.json @@ -47,7 +47,7 @@ "dependencies": { "earcut": "^2.2.3", "geotiff": "2.0.4", - "ol-mapbox-style": "8.2.0", + "ol-mapbox-style": "8.2.1", "pbf": "3.2.1", "rbush": "^3.0.1" }, diff --git a/src/ol/Map.js b/src/ol/Map.js index 7d26977177..e051162613 100644 --- a/src/ol/Map.js +++ b/src/ol/Map.js @@ -3,7 +3,6 @@ */ import CompositeMapRenderer from './renderer/Composite.js'; import PluggableMap from './PluggableMap.js'; -import {assign} from './obj.js'; import {defaults as defaultControls} from './control.js'; import {defaults as defaultInteractions} from './interaction.js'; @@ -59,7 +58,7 @@ class Map extends PluggableMap { * @param {import("./PluggableMap.js").MapOptions} options Map options. */ constructor(options) { - options = assign({}, options); + options = Object.assign({}, options); if (!options.controls) { options.controls = defaultControls(); } diff --git a/src/ol/Object.js b/src/ol/Object.js index 2ea88e9764..1d8e1b07cc 100644 --- a/src/ol/Object.js +++ b/src/ol/Object.js @@ -4,8 +4,8 @@ import Event from './events/Event.js'; import ObjectEventType from './ObjectEventType.js'; import Observable from './Observable.js'; -import {assign, isEmpty} from './obj.js'; import {getUid} from './util.js'; +import {isEmpty} from './obj.js'; /** * @classdesc @@ -155,7 +155,7 @@ class BaseObject extends Observable { * @api */ getProperties() { - return (this.values_ && assign({}, this.values_)) || {}; + return (this.values_ && Object.assign({}, this.values_)) || {}; } /** @@ -239,7 +239,7 @@ class BaseObject extends Observable { if (!source.values_) { return; } - assign(this.values_ || (this.values_ = {}), source.values_); + Object.assign(this.values_ || (this.values_ = {}), source.values_); } /** diff --git a/src/ol/View.js b/src/ol/View.js index 1409f5cd7d..f7409fa3c2 100644 --- a/src/ol/View.js +++ b/src/ol/View.js @@ -24,7 +24,6 @@ import { rotate as rotateCoordinate, } from './coordinate.js'; import {assert} from './asserts.js'; -import {assign} from './obj.js'; import {none as centerNone, createExtent} from './centerconstraint.js'; import {clamp, modulo} from './math.js'; import { @@ -325,7 +324,7 @@ class View extends BaseObject { */ this.un; - const options = assign({}, opt_options); + const options = Object.assign({}, opt_options); /** * @private @@ -418,7 +417,7 @@ class View extends BaseObject { * @param {ViewOptions} options View options. */ applyOptions_(options) { - const properties = assign({}, options); + const properties = Object.assign({}, options); for (const key in ViewProperty) { delete properties[key]; } @@ -541,7 +540,7 @@ class View extends BaseObject { // preserve rotation options.rotation = this.getRotation(); - return assign({}, options, newOptions); + return Object.assign({}, options, newOptions); } /** @@ -585,14 +584,14 @@ class View extends BaseObject { for (let i = 0; i < args.length; ++i) { let options = arguments[i]; if (options.center) { - options = assign({}, options); + options = Object.assign({}, options); options.center = fromUserCoordinate( options.center, this.getProjection() ); } if (options.anchor) { - options = assign({}, options); + options = Object.assign({}, options); options.anchor = fromUserCoordinate( options.anchor, this.getProjection() diff --git a/src/ol/format/EsriJSON.js b/src/ol/format/EsriJSON.js index 164f7d5acf..9650e565bb 100644 --- a/src/ol/format/EsriJSON.js +++ b/src/ol/format/EsriJSON.js @@ -11,10 +11,10 @@ import MultiPolygon from '../geom/MultiPolygon.js'; import Point from '../geom/Point.js'; import Polygon from '../geom/Polygon.js'; import {assert} from '../asserts.js'; -import {assign, isEmpty} from '../obj.js'; import {containsExtent} from '../extent.js'; import {deflateCoordinates} from '../geom/flat/deflate.js'; import {get as getProjection} from '../proj.js'; +import {isEmpty} from '../obj.js'; import {linearRingIsClockwise} from '../geom/flat/orient.js'; import {transformGeometryWithOptions} from './Feature.js'; @@ -274,10 +274,10 @@ function readGeometry(object, opt_options) { const rings = convertRings(esriJSONPolygon.rings, layout); if (rings.length === 1) { type = 'Polygon'; - object = assign({}, object, {['rings']: rings[0]}); + object = Object.assign({}, object, {['rings']: rings[0]}); } else { type = 'MultiPolygon'; - object = assign({}, object, {['rings']: rings}); + object = Object.assign({}, object, {['rings']: rings}); } } const geometryReader = GEOMETRY_READERS[type]; diff --git a/src/ol/format/Feature.js b/src/ol/format/Feature.js index f9ecf655bb..d698e843c8 100644 --- a/src/ol/format/Feature.js +++ b/src/ol/format/Feature.js @@ -3,7 +3,6 @@ */ import Units from '../proj/Units.js'; import {abstract} from '../util.js'; -import {assign} from '../obj.js'; import { equivalent as equivalentProjection, get as getProjection, @@ -127,7 +126,7 @@ class FeatureFormat { * Updated options. */ adaptOptions(options) { - return assign( + return Object.assign( { dataProjection: this.dataProjection, featureProjection: this.defaultFeatureProjection, diff --git a/src/ol/format/GML2.js b/src/ol/format/GML2.js index a480d9b157..7753a661b9 100644 --- a/src/ol/format/GML2.js +++ b/src/ol/format/GML2.js @@ -13,7 +13,6 @@ import { pushParseAndPop, pushSerializeAndPop, } from '../xml.js'; -import {assign} from '../obj.js'; import {createOrUpdate} from '../extent.js'; import {get as getProjection} from '../proj.js'; import { @@ -245,7 +244,7 @@ class GML2 extends GMLBase { } } } - const item = assign({}, context); + const item = Object.assign({}, context); item.node = node; pushSerializeAndPop( /** @type {import("../xml.js").NodeStackItem} */ @@ -330,7 +329,7 @@ class GML2 extends GMLBase { const context = /** @type {import("./Feature.js").WriteOptions} */ ( objectStack[objectStack.length - 1] ); - const item = assign({}, context); + const item = Object.assign({}, context); item['node'] = node; let value; if (Array.isArray(geometry)) { diff --git a/src/ol/format/GML3.js b/src/ol/format/GML3.js index d4143d62d8..da833424fd 100644 --- a/src/ol/format/GML3.js +++ b/src/ol/format/GML3.js @@ -21,7 +21,6 @@ import { pushParseAndPop, pushSerializeAndPop, } from '../xml.js'; -import {assign} from '../obj.js'; import {createOrUpdate} from '../extent.js'; import {extend} from '../array.js'; import {get as getProjection} from '../proj.js'; @@ -815,7 +814,7 @@ class GML3 extends GMLBase { const context = /** @type {import("./Feature.js").WriteOptions} */ ( objectStack[objectStack.length - 1] ); - const item = assign({}, context); + const item = Object.assign({}, context); item['node'] = node; let value; if (Array.isArray(geometry)) { @@ -888,7 +887,7 @@ class GML3 extends GMLBase { } } } - const item = assign({}, context); + const item = Object.assign({}, context); item.node = node; pushSerializeAndPop( /** @type {import("../xml.js").NodeStackItem} */ @@ -918,7 +917,7 @@ class GML3 extends GMLBase { this.writeFeatureElement, this ); - const item = assign({}, context); + const item = Object.assign({}, context); item.node = node; pushSerializeAndPop( /** @type {import("../xml.js").NodeStackItem} */ @@ -1001,7 +1000,7 @@ class GML3 extends GMLBase { multiCurve: this.multiCurve_, }; if (opt_options) { - assign(context, opt_options); + Object.assign(context, opt_options); } this.writeGeometryElement(geom, geometry, [context]); return geom; @@ -1034,7 +1033,7 @@ class GML3 extends GMLBase { featureType: this.featureType, }; if (opt_options) { - assign(context, opt_options); + Object.assign(context, opt_options); } this.writeFeatureMembers_(node, features, [context]); return node; diff --git a/src/ol/format/GMLBase.js b/src/ol/format/GMLBase.js index c348c2d09e..bfd8cb4025 100644 --- a/src/ol/format/GMLBase.js +++ b/src/ol/format/GMLBase.js @@ -13,7 +13,6 @@ import MultiPolygon from '../geom/MultiPolygon.js'; import Point from '../geom/Point.js'; import Polygon from '../geom/Polygon.js'; import XMLFeature from './XMLFeature.js'; -import {assign} from '../obj.js'; import {extend} from '../array.js'; import { getAllTextContent, @@ -570,7 +569,7 @@ class GMLBase extends XMLFeature { featureNS: this.featureNS, }; if (opt_options) { - assign(options, this.getReadOptions(node, opt_options)); + Object.assign(options, this.getReadOptions(node, opt_options)); } const features = this.readFeaturesInternal(node, [options]); return features || []; diff --git a/src/ol/format/GeoJSON.js b/src/ol/format/GeoJSON.js index d7cd11911a..e261dfacf9 100644 --- a/src/ol/format/GeoJSON.js +++ b/src/ol/format/GeoJSON.js @@ -12,8 +12,8 @@ import MultiPolygon from '../geom/MultiPolygon.js'; import Point from '../geom/Point.js'; import Polygon from '../geom/Polygon.js'; import {assert} from '../asserts.js'; -import {assign, isEmpty} from '../obj.js'; import {get as getProjection} from '../proj.js'; +import {isEmpty} from '../obj.js'; import {transformGeometryWithOptions} from './Feature.js'; /** @@ -476,7 +476,7 @@ function writeGeometry(geometry, opt_options) { */ function writeGeometryCollectionGeometry(geometry, opt_options) { const geometries = geometry.getGeometriesArray().map(function (geometry) { - const options = assign({}, opt_options); + const options = Object.assign({}, opt_options); delete options.featureProjection; return writeGeometry(geometry, options); }); diff --git a/src/ol/format/WFS.js b/src/ol/format/WFS.js index b21f3c7395..88570faaf6 100644 --- a/src/ol/format/WFS.js +++ b/src/ol/format/WFS.js @@ -21,7 +21,6 @@ import { } from '../xml.js'; import {and as andFilterFn, bbox as bboxFilterFn} from './filter.js'; import {assert} from '../asserts.js'; -import {assign} from '../obj.js'; import {get as getProjection} from '../proj.js'; import { readNonNegativeIntegerString, @@ -333,12 +332,15 @@ class WFS extends XMLFeature { const context = { node, }; - assign(context, { + Object.assign(context, { 'featureType': this.featureType_, 'featureNS': this.featureNS_, }); - assign(context, this.getReadOptions(node, opt_options ? opt_options : {})); + Object.assign( + context, + this.getReadOptions(node, opt_options ? opt_options : {}) + ); const objectStack = [context]; let featuresNS; if (this.version_ === '2.0.0') { @@ -511,7 +513,7 @@ class WFS extends XMLFeature { const context = { node, }; - assign(context, { + Object.assign(context, { 'version': this.version_, 'srsName': options.srsName, 'featureNS': options.featureNS ? options.featureNS : this.featureNS_, @@ -530,7 +532,7 @@ class WFS extends XMLFeature { filter ); } - assign(context, { + Object.assign(context, { 'geometryName': options.geometryName, 'filter': filter, }); @@ -548,7 +550,7 @@ class WFS extends XMLFeature { options.srsName, options.filter ); - assign(context, { + Object.assign(context, { 'geometryName': featureType.geometryName, 'filter': completeFilter, }); @@ -686,7 +688,7 @@ function createTransactionRequest(node, baseObj, version, options) { } else if (version === '2.0.0') { gmlVersion = 3.2; } - const obj = assign( + const obj = Object.assign( {node}, { version, @@ -1035,7 +1037,7 @@ function writeQuery(node, featureType, objectStack) { node.setAttributeNS(XMLNS, 'xmlns:' + featurePrefix, featureNS); } const item = /** @type {import("../xml.js").NodeStackItem} */ ( - assign({}, context) + Object.assign({}, context) ); item.node = node; pushSerializeAndPop( @@ -1062,7 +1064,7 @@ function writeFilterCondition(node, filter, objectStack) { const context = /** @type {Object} */ (objectStack[objectStack.length - 1]); /** @type {import("../xml.js").NodeStackItem} */ const item = {node}; - assign(item, {context}); + Object.assign(item, {context}); pushSerializeAndPop( item, GETFEATURE_SERIALIZERS, @@ -1167,7 +1169,7 @@ function writeLogicalFilter(node, filter, objectStack) { const context = parent['context']; /** @type {import("../xml.js").NodeStackItem} */ const item = {node}; - assign(item, {context}); + Object.assign(item, {context}); const conditions = filter.conditions; for (let i = 0, ii = conditions.length; i < ii; ++i) { const condition = conditions[i]; @@ -1191,7 +1193,7 @@ function writeNotFilter(node, filter, objectStack) { const context = parent['context']; /** @type {import("../xml.js").NodeStackItem} */ const item = {node}; - assign(item, {context}); + Object.assign(item, {context}); const condition = filter.condition; pushSerializeAndPop( item, @@ -1332,7 +1334,7 @@ export function writeFilter(filter, opt_version) { const context = { node: child, }; - assign(context, { + Object.assign(context, { 'version': version, 'filter': filter, }); @@ -1348,7 +1350,7 @@ export function writeFilter(filter, opt_version) { function writeGetFeature(node, featureTypes, objectStack) { const context = /** @type {Object} */ (objectStack[objectStack.length - 1]); const item = /** @type {import("../xml.js").NodeStackItem} */ ( - assign({}, context) + Object.assign({}, context) ); item.node = node; pushSerializeAndPop( diff --git a/src/ol/format/WKB.js b/src/ol/format/WKB.js index 1b75d51333..76de421142 100644 --- a/src/ol/format/WKB.js +++ b/src/ol/format/WKB.js @@ -13,7 +13,6 @@ import Polygon from '../geom/Polygon.js'; import {get as getProjection} from '../proj.js'; import SimpleGeometry from '../geom/SimpleGeometry.js'; -import {assign} from '../obj.js'; // WKB spec: https://www.ogc.org/standards/sfa // EWKB spec: https://raw.githubusercontent.com/postgis/postgis/2.1.0/doc/ZMSgeoms.txt @@ -423,7 +422,7 @@ class WkbWriter { * @property {number} Z NoData value for Z * @property {number} M NoData value for M */ - this.nodata_ = assign({X: 0, Y: 0, Z: 0, M: 0}, opts.nodata); + this.nodata_ = Object.assign({X: 0, Y: 0, Z: 0, M: 0}, opts.nodata); } /** @@ -459,7 +458,7 @@ class WkbWriter { * @property {number} [Z] NoData value for Z * @property {number} [M] NoData value for M */ - const coordsObj = assign.apply( + const coordsObj = Object.assign.apply( null, layout.split('').map((axis, idx) => ({[axis]: coords[idx]})) ); diff --git a/src/ol/format/WMSGetFeatureInfo.js b/src/ol/format/WMSGetFeatureInfo.js index e03b04dcc4..88cd0f33e3 100644 --- a/src/ol/format/WMSGetFeatureInfo.js +++ b/src/ol/format/WMSGetFeatureInfo.js @@ -3,7 +3,6 @@ */ import GML2 from './GML2.js'; import XMLFeature from './XMLFeature.js'; -import {assign} from '../obj.js'; import {extend} from '../array.js'; import {makeArrayPusher, makeStructureNS, pushParseAndPop} from '../xml.js'; @@ -157,7 +156,7 @@ class WMSGetFeatureInfo extends XMLFeature { readFeaturesFromNode(node, opt_options) { const options = {}; if (opt_options) { - assign(options, this.getReadOptions(node, opt_options)); + Object.assign(options, this.getReadOptions(node, opt_options)); } return this.readFeatures_(node, [options]); } diff --git a/src/ol/interaction/Link.js b/src/ol/interaction/Link.js index af0dfeef75..0395f66f96 100644 --- a/src/ol/interaction/Link.js +++ b/src/ol/interaction/Link.js @@ -4,7 +4,6 @@ import EventType from '../events/EventType.js'; import Interaction from './Interaction.js'; import MapEventType from '../MapEventType.js'; -import {assign} from '../obj.js'; import {listen, unlistenByKey} from '../events.js'; import {toFixed} from '../math.js'; @@ -76,7 +75,7 @@ class Link extends Interaction { constructor(opt_options) { super(); - const options = assign( + const options = Object.assign( {animate: true, replace: false, prefix: ''}, opt_options || {} ); @@ -282,7 +281,7 @@ class Link extends Interaction { if (updateView) { if (!this.initial_ && this.animationOptions_) { - view.animate(assign(viewProperties, this.animationOptions_)); + view.animate(Object.assign(viewProperties, this.animationOptions_)); } else { if (viewProperties.center) { view.setCenter(viewProperties.center); diff --git a/src/ol/layer/Base.js b/src/ol/layer/Base.js index 1b500de820..b86b21fff2 100644 --- a/src/ol/layer/Base.js +++ b/src/ol/layer/Base.js @@ -5,7 +5,6 @@ import BaseObject from '../Object.js'; import LayerProperty from './Property.js'; import {abstract} from '../util.js'; import {assert} from '../asserts.js'; -import {assign} from '../obj.js'; import {clamp} from '../math.js'; /** @@ -92,10 +91,10 @@ class BaseLayer extends BaseObject { /** * @type {Object} */ - const properties = assign({}, options); + const properties = Object.assign({}, options); if (typeof options.properties === 'object') { delete properties.properties; - assign(properties, options.properties); + Object.assign(properties, options.properties); } properties[LayerProperty.OPACITY] = diff --git a/src/ol/layer/BaseTile.js b/src/ol/layer/BaseTile.js index b41f3c9be2..b8f872b99c 100644 --- a/src/ol/layer/BaseTile.js +++ b/src/ol/layer/BaseTile.js @@ -3,7 +3,6 @@ */ import Layer from './Layer.js'; import TileProperty from './TileProperty.js'; -import {assign} from '../obj.js'; /*** * @template Return @@ -66,7 +65,7 @@ class BaseTileLayer extends Layer { constructor(opt_options) { const options = opt_options ? opt_options : {}; - const baseOptions = assign({}, options); + const baseOptions = Object.assign({}, options); delete baseOptions.preload; delete baseOptions.useInterimTilesOnError; diff --git a/src/ol/layer/BaseVector.js b/src/ol/layer/BaseVector.js index 682fc2dfd3..1b41a7e3a1 100644 --- a/src/ol/layer/BaseVector.js +++ b/src/ol/layer/BaseVector.js @@ -3,7 +3,6 @@ */ import Layer from './Layer.js'; import RBush from 'rbush'; -import {assign} from '../obj.js'; import { createDefaultStyle, toFunction as toStyleFunction, @@ -91,7 +90,7 @@ class BaseVectorLayer extends Layer { constructor(opt_options) { const options = opt_options ? opt_options : {}; - const baseOptions = assign({}, options); + const baseOptions = Object.assign({}, options); delete baseOptions.style; delete baseOptions.renderBuffer; diff --git a/src/ol/layer/Graticule.js b/src/ol/layer/Graticule.js index 03a99d3847..ee597e7d2c 100644 --- a/src/ol/layer/Graticule.js +++ b/src/ol/layer/Graticule.js @@ -25,7 +25,6 @@ import { isEmpty, wrapX as wrapExtentX, } from '../extent.js'; -import {assign} from '../obj.js'; import {clamp} from '../math.js'; import {degreesToStringHDMS} from '../coordinate.js'; import { @@ -170,7 +169,7 @@ class Graticule extends VectorLayer { constructor(opt_options) { const options = opt_options ? opt_options : {}; - const baseOptions = assign( + const baseOptions = Object.assign( { updateWhileAnimating: true, updateWhileInteracting: true, diff --git a/src/ol/layer/Group.js b/src/ol/layer/Group.js index a0d5168849..72cbf0c855 100644 --- a/src/ol/layer/Group.js +++ b/src/ol/layer/Group.js @@ -8,7 +8,7 @@ import Event from '../events/Event.js'; import EventType from '../events/EventType.js'; import ObjectEventType from '../ObjectEventType.js'; import {assert} from '../asserts.js'; -import {assign, clear} from '../obj.js'; +import {clear} from '../obj.js'; import {getIntersection} from '../extent.js'; import {getUid} from '../util.js'; import {listen, unlistenByKey} from '../events.js'; @@ -92,7 +92,7 @@ class LayerGroup extends BaseLayer { */ constructor(opt_options) { const options = opt_options || {}; - const baseOptions = /** @type {Options} */ (assign({}, options)); + const baseOptions = /** @type {Options} */ (Object.assign({}, options)); delete baseOptions.layers; let layers = options.layers; diff --git a/src/ol/layer/Heatmap.js b/src/ol/layer/Heatmap.js index 5d2fb598c5..11560330f6 100644 --- a/src/ol/layer/Heatmap.js +++ b/src/ol/layer/Heatmap.js @@ -3,7 +3,6 @@ */ import BaseVector from './BaseVector.js'; import WebGLPointsLayerRenderer from '../renderer/webgl/PointsLayer.js'; -import {assign} from '../obj.js'; import {clamp} from '../math.js'; import {createCanvasContext2D} from '../dom.js'; @@ -71,7 +70,7 @@ class Heatmap extends BaseVector { constructor(opt_options) { const options = opt_options ? opt_options : {}; - const baseOptions = assign({}, options); + const baseOptions = Object.assign({}, options); delete baseOptions.gradient; delete baseOptions.radius; diff --git a/src/ol/layer/Layer.js b/src/ol/layer/Layer.js index c40412be60..d77041cf5a 100644 --- a/src/ol/layer/Layer.js +++ b/src/ol/layer/Layer.js @@ -6,7 +6,6 @@ import EventType from '../events/EventType.js'; import LayerProperty from './Property.js'; import RenderEventType from '../render/EventType.js'; import {assert} from '../asserts.js'; -import {assign} from '../obj.js'; import {listen, unlistenByKey} from '../events.js'; /** @@ -95,7 +94,7 @@ class Layer extends BaseLayer { * @param {Options} options Layer options. */ constructor(options) { - const baseOptions = assign({}, options); + const baseOptions = Object.assign({}, options); delete baseOptions.source; super(baseOptions); diff --git a/src/ol/layer/VectorImage.js b/src/ol/layer/VectorImage.js index 3487562c52..fe30cf6200 100644 --- a/src/ol/layer/VectorImage.js +++ b/src/ol/layer/VectorImage.js @@ -3,7 +3,6 @@ */ import BaseVectorLayer from './BaseVector.js'; import CanvasVectorImageLayerRenderer from '../renderer/canvas/VectorImageLayer.js'; -import {assign} from '../obj.js'; /** * @template {import("../source/Vector.js").default} VectorSourceType @@ -69,7 +68,7 @@ class VectorImageLayer extends BaseVectorLayer { constructor(opt_options) { const options = opt_options ? opt_options : {}; - const baseOptions = assign({}, options); + const baseOptions = Object.assign({}, options); delete baseOptions.imageRatio; super(baseOptions); diff --git a/src/ol/layer/VectorTile.js b/src/ol/layer/VectorTile.js index 71ef266ad7..1a6be48eae 100644 --- a/src/ol/layer/VectorTile.js +++ b/src/ol/layer/VectorTile.js @@ -6,7 +6,6 @@ import CanvasVectorTileLayerRenderer from '../renderer/canvas/VectorTileLayer.js import TileProperty from './TileProperty.js'; import VectorTileRenderType from './VectorTileRenderType.js'; import {assert} from '../asserts.js'; -import {assign} from '../obj.js'; /*** * @template Return @@ -102,7 +101,7 @@ class VectorTileLayer extends BaseVectorLayer { constructor(opt_options) { const options = opt_options ? opt_options : {}; - const baseOptions = /** @type {Object} */ (assign({}, options)); + const baseOptions = /** @type {Object} */ (Object.assign({}, options)); delete baseOptions.preload; delete baseOptions.useInterimTilesOnError; diff --git a/src/ol/layer/WebGLPoints.js b/src/ol/layer/WebGLPoints.js index 662ec3f6ec..721d761bcd 100644 --- a/src/ol/layer/WebGLPoints.js +++ b/src/ol/layer/WebGLPoints.js @@ -3,7 +3,6 @@ */ import Layer from './Layer.js'; import WebGLPointsLayerRenderer from '../renderer/webgl/PointsLayer.js'; -import {assign} from '../obj.js'; import {parseLiteralStyle} from '../webgl/ShaderBuilder.js'; /** @@ -77,7 +76,7 @@ class WebGLPointsLayer extends Layer { * @param {Options} options Options. */ constructor(options) { - const baseOptions = assign({}, options); + const baseOptions = Object.assign({}, options); super(baseOptions); @@ -120,7 +119,7 @@ class WebGLPointsLayer extends Layer { * @param {Object} variables Variables to update. */ updateStyleVariables(variables) { - assign(this.styleVariables_, variables); + Object.assign(this.styleVariables_, variables); this.changed(); } } diff --git a/src/ol/layer/WebGLTile.js b/src/ol/layer/WebGLTile.js index 1dcb919e84..a35d518bb1 100644 --- a/src/ol/layer/WebGLTile.js +++ b/src/ol/layer/WebGLTile.js @@ -14,7 +14,6 @@ import { getStringNumberEquivalent, uniformNameForVariable, } from '../style/expressions.js'; -import {assign} from '../obj.js'; /** * @typedef {import("../source/DataTile.js").default|import("../source/TileImage.js").default} SourceType @@ -308,7 +307,7 @@ class WebGLTileLayer extends BaseTileLayer { * @param {Options} opt_options Tile layer options. */ constructor(opt_options) { - const options = opt_options ? assign({}, opt_options) : {}; + const options = opt_options ? Object.assign({}, opt_options) : {}; const style = options.style || {}; delete options.style; @@ -511,7 +510,7 @@ class WebGLTileLayer extends BaseTileLayer { * @api */ updateStyleVariables(variables) { - assign(this.styleVariables_, variables); + Object.assign(this.styleVariables_, variables); this.changed(); } } diff --git a/src/ol/obj.js b/src/ol/obj.js index e95e39d237..2218ccf354 100644 --- a/src/ol/obj.js +++ b/src/ol/obj.js @@ -2,37 +2,6 @@ * @module ol/obj */ -/** - * Polyfill for Object.assign(). Assigns enumerable and own properties from - * one or more source objects to a target object. - * See https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Object/assign. - * - * @param {!Object} target The target object. - * @param {...Object} var_sources The source object(s). - * @return {!Object} The modified target object. - */ -export const assign = - typeof Object.assign === 'function' - ? Object.assign - : function (target, var_sources) { - if (target === undefined || target === null) { - throw new TypeError('Cannot convert undefined or null to object'); - } - - const output = Object(target); - for (let i = 1, ii = arguments.length; i < ii; ++i) { - const source = arguments[i]; - if (source !== undefined && source !== null) { - for (const key in source) { - if (source.hasOwnProperty(key)) { - output[key] = source[key]; - } - } - } - } - return output; - }; - /** * Removes all properties from an object. * @param {Object} object The object to clear. diff --git a/src/ol/renderer/canvas/ImageLayer.js b/src/ol/renderer/canvas/ImageLayer.js index 4e8bad601e..23f505e7c7 100644 --- a/src/ol/renderer/canvas/ImageLayer.js +++ b/src/ol/renderer/canvas/ImageLayer.js @@ -12,7 +12,6 @@ import { makeInverse, toString as toTransformString, } from '../../transform.js'; -import {assign} from '../../obj.js'; import { containsCoordinate, containsExtent, @@ -239,7 +238,7 @@ class CanvasImageLayerRenderer extends CanvasLayerRenderer { const dh = img.height * transform[3]; if (!this.getLayer().getSource().getInterpolate()) { - assign(context, IMAGE_SMOOTHING_DISABLED); + Object.assign(context, IMAGE_SMOOTHING_DISABLED); } this.preRender(context, frameState); @@ -262,7 +261,7 @@ class CanvasImageLayerRenderer extends CanvasLayerRenderer { if (clipped) { context.restore(); } - assign(context, IMAGE_SMOOTHING_ENABLED); + Object.assign(context, IMAGE_SMOOTHING_ENABLED); if (canvasTransform !== canvas.style.transform) { canvas.style.transform = canvasTransform; diff --git a/src/ol/renderer/canvas/TileLayer.js b/src/ol/renderer/canvas/TileLayer.js index 671cffb1ac..63a9bd8dc4 100644 --- a/src/ol/renderer/canvas/TileLayer.js +++ b/src/ol/renderer/canvas/TileLayer.js @@ -13,7 +13,6 @@ import { makeInverse, toString as toTransformString, } from '../../transform.js'; -import {assign} from '../../obj.js'; import { containsCoordinate, createEmpty, @@ -411,7 +410,7 @@ class CanvasTileLayerRenderer extends CanvasLayerRenderer { } if (!tileSource.getInterpolate()) { - assign(context, IMAGE_SMOOTHING_DISABLED); + Object.assign(context, IMAGE_SMOOTHING_DISABLED); } this.preRender(context, frameState); @@ -562,7 +561,7 @@ class CanvasTileLayerRenderer extends CanvasLayerRenderer { if (layerState.extent) { context.restore(); } - assign(context, IMAGE_SMOOTHING_ENABLED); + Object.assign(context, IMAGE_SMOOTHING_ENABLED); if (canvasTransform !== canvas.style.transform) { canvas.style.transform = canvasTransform; diff --git a/src/ol/renderer/canvas/VectorImageLayer.js b/src/ol/renderer/canvas/VectorImageLayer.js index 75948f710c..c643faf58a 100644 --- a/src/ol/renderer/canvas/VectorImageLayer.js +++ b/src/ol/renderer/canvas/VectorImageLayer.js @@ -9,7 +9,6 @@ import ImageState from '../../ImageState.js'; import RBush from 'rbush'; import ViewHint from '../../ViewHint.js'; import {apply, compose, create} from '../../transform.js'; -import {assign} from '../../obj.js'; import {getHeight, getWidth, isEmpty, scaleFromCenter} from '../../extent.js'; /** @@ -109,15 +108,15 @@ class CanvasVectorImageLayerRenderer extends CanvasImageLayerRenderer { const context = vectorRenderer.context; const layerState = frameState.layerStatesArray[frameState.layerIndex]; context.globalAlpha = layerState.opacity; - const imageLayerState = assign({}, layerState, {opacity: 1}); + const imageLayerState = Object.assign({}, layerState, {opacity: 1}); const imageFrameState = /** @type {import("../../PluggableMap.js").FrameState} */ ( - assign({}, frameState, { + Object.assign({}, frameState, { declutterTree: new RBush(9), extent: renderedExtent, size: [width, height], viewState: /** @type {import("../../View.js").State} */ ( - assign({}, frameState.viewState, { + Object.assign({}, frameState.viewState, { rotation: 0, }) ), diff --git a/src/ol/reproj.js b/src/ol/reproj.js index 06b427b3d0..eb7d58d3e0 100644 --- a/src/ol/reproj.js +++ b/src/ol/reproj.js @@ -2,7 +2,6 @@ * @module ol/reproj */ import {IMAGE_SMOOTHING_DISABLED} from './renderer/canvas/common.js'; -import {assign} from './obj.js'; import { containsCoordinate, createEmpty, @@ -227,7 +226,7 @@ export function render( ); if (!opt_interpolate) { - assign(context, IMAGE_SMOOTHING_DISABLED); + Object.assign(context, IMAGE_SMOOTHING_DISABLED); } if (sources.length === 0) { @@ -255,7 +254,7 @@ export function render( ); if (!opt_interpolate) { - assign(stitchContext, IMAGE_SMOOTHING_DISABLED); + Object.assign(stitchContext, IMAGE_SMOOTHING_DISABLED); } const stitchScale = pixelRatio / sourceResolution; diff --git a/src/ol/source/CartoDB.js b/src/ol/source/CartoDB.js index 008f06949c..77fde10b5c 100644 --- a/src/ol/source/CartoDB.js +++ b/src/ol/source/CartoDB.js @@ -3,7 +3,6 @@ */ import XYZ from './XYZ.js'; -import {assign} from '../obj.js'; /** * @typedef {Object} Options @@ -104,7 +103,7 @@ class CartoDB extends XYZ { * @api */ updateConfig(config) { - assign(this.config_, config); + Object.assign(this.config_, config); this.initializeMap_(); } diff --git a/src/ol/source/DataTile.js b/src/ol/source/DataTile.js index ad7af2e836..c8991df83c 100644 --- a/src/ol/source/DataTile.js +++ b/src/ol/source/DataTile.js @@ -6,7 +6,6 @@ import EventType from '../events/EventType.js'; import TileEventType from './TileEventType.js'; import TileSource, {TileSourceEvent} from './Tile.js'; import TileState from '../TileState.js'; -import {assign} from '../obj.js'; import {createXYZ, extentFromProjection} from '../tilegrid.js'; import {getKeyZXY} from '../tilecoord.js'; import {getUid} from '../util.js'; @@ -197,7 +196,7 @@ class DataTileSource extends TileSource { }); } - const options = assign( + const options = Object.assign( { tileCoord: [z, x, y], loader: loader, diff --git a/src/ol/source/ImageArcGISRest.js b/src/ol/source/ImageArcGISRest.js index 9f385dfa1e..038fad4c41 100644 --- a/src/ol/source/ImageArcGISRest.js +++ b/src/ol/source/ImageArcGISRest.js @@ -7,7 +7,6 @@ import ImageSource, {defaultImageLoadFunction} from './Image.js'; import ImageWrapper from '../Image.js'; import {appendParams} from '../uri.js'; import {assert} from '../asserts.js'; -import {assign} from '../obj.js'; import {containsExtent, getHeight, getWidth} from '../extent.js'; /** @@ -172,7 +171,7 @@ class ImageArcGISRest extends ImageSource { 'FORMAT': 'PNG32', 'TRANSPARENT': true, }; - assign(params, this.params_); + Object.assign(params, this.params_); extent = extent.slice(); const centerX = (extent[0] + extent[2]) / 2; @@ -311,7 +310,7 @@ class ImageArcGISRest extends ImageSource { * @api */ updateParams(params) { - assign(this.params_, params); + Object.assign(this.params_, params); this.image_ = null; this.changed(); } diff --git a/src/ol/source/ImageMapGuide.js b/src/ol/source/ImageMapGuide.js index e60281982e..710d001bc9 100644 --- a/src/ol/source/ImageMapGuide.js +++ b/src/ol/source/ImageMapGuide.js @@ -6,7 +6,6 @@ import EventType from '../events/EventType.js'; import ImageSource, {defaultImageLoadFunction} from './Image.js'; import ImageWrapper from '../Image.js'; import {appendParams} from '../uri.js'; -import {assign} from '../obj.js'; import { containsExtent, getCenter, @@ -220,7 +219,7 @@ class ImageMapGuide extends ImageSource { * @api */ updateParams(params) { - assign(this.params_, params); + Object.assign(this.params_, params); this.changed(); } @@ -250,7 +249,7 @@ class ImageMapGuide extends ImageSource { 'SETVIEWCENTERX': center[0], 'SETVIEWCENTERY': center[1], }; - assign(baseParams, params); + Object.assign(baseParams, params); return appendParams(baseUrl, baseParams); } diff --git a/src/ol/source/ImageStatic.js b/src/ol/source/ImageStatic.js index de7ae14f1e..d2cc158d85 100644 --- a/src/ol/source/ImageStatic.js +++ b/src/ol/source/ImageStatic.js @@ -7,7 +7,6 @@ import ImageSource, {defaultImageLoadFunction} from './Image.js'; import ImageState from '../ImageState.js'; import ImageWrapper from '../Image.js'; import {IMAGE_SMOOTHING_DISABLED} from '../renderer/canvas/common.js'; -import {assign} from '../obj.js'; import {createCanvasContext2D} from '../dom.js'; import {getHeight, getWidth, intersects} from '../extent.js'; import {get as getProjection} from '../proj.js'; @@ -158,7 +157,7 @@ class Static extends ImageSource { if (targetWidth !== imageWidth || targetHeight !== imageHeight) { const context = createCanvasContext2D(targetWidth, targetHeight); if (!this.getInterpolate()) { - assign(context, IMAGE_SMOOTHING_DISABLED); + Object.assign(context, IMAGE_SMOOTHING_DISABLED); } const canvas = context.canvas; context.drawImage( diff --git a/src/ol/source/ImageWMS.js b/src/ol/source/ImageWMS.js index 34a6315f99..41f9552d35 100644 --- a/src/ol/source/ImageWMS.js +++ b/src/ol/source/ImageWMS.js @@ -8,7 +8,6 @@ import ImageWrapper from '../Image.js'; import {DEFAULT_VERSION} from './wms.js'; import {appendParams} from '../uri.js'; import {assert} from '../asserts.js'; -import {assign} from '../obj.js'; import {calculateSourceResolution} from '../reproj.js'; import {ceil, floor, round} from '../math.js'; import {compareVersions} from '../string.js'; @@ -206,7 +205,7 @@ class ImageWMS extends ImageSource { 'TRANSPARENT': true, 'QUERY_LAYERS': this.params_['LAYERS'], }; - assign(baseParams, this.params_, params); + Object.assign(baseParams, this.params_, params); const x = floor((coordinate[0] - extent[0]) / resolution, DECIMALS); const y = floor((extent[3] - coordinate[1]) / resolution, DECIMALS); @@ -265,7 +264,7 @@ class ImageWMS extends ImageSource { baseParams['SCALE'] = (resolution * mpu) / pixelSize; } - assign(baseParams, params); + Object.assign(baseParams, params); return appendParams(/** @type {string} */ (this.url_), baseParams); } @@ -338,7 +337,7 @@ class ImageWMS extends ImageSource { 'FORMAT': 'image/png', 'TRANSPARENT': true, }; - assign(params, this.params_); + Object.assign(params, this.params_); this.imageSize_[0] = round( getWidth(requestExtent) / imageResolution, @@ -480,7 +479,7 @@ class ImageWMS extends ImageSource { * @api */ updateParams(params) { - assign(this.params_, params); + Object.assign(this.params_, params); this.updateV13_(); this.image_ = null; this.changed(); diff --git a/src/ol/source/Raster.js b/src/ol/source/Raster.js index 9fc248abd5..b3c3464934 100644 --- a/src/ol/source/Raster.js +++ b/src/ol/source/Raster.js @@ -11,7 +11,6 @@ import Source from './Source.js'; import TileLayer from '../layer/Tile.js'; import TileQueue from '../TileQueue.js'; import TileSource from './Tile.js'; -import {assign} from '../obj.js'; import {createCanvasContext2D} from '../dom.js'; import {create as createTransform} from '../transform.js'; import {equals, getCenter, getHeight, getWidth} from '../extent.js'; @@ -711,11 +710,11 @@ class RasterSource extends ImageSource { */ updateFrameState_(extent, resolution, projection) { const frameState = /** @type {import("../PluggableMap.js").FrameState} */ ( - assign({}, this.frameState_) + Object.assign({}, this.frameState_) ); frameState.viewState = /** @type {import("../View.js").State} */ ( - assign({}, frameState.viewState) + Object.assign({}, frameState.viewState) ); const center = getCenter(extent); diff --git a/src/ol/source/TileArcGISRest.js b/src/ol/source/TileArcGISRest.js index 55f0d65f3c..091d54c538 100644 --- a/src/ol/source/TileArcGISRest.js +++ b/src/ol/source/TileArcGISRest.js @@ -4,7 +4,6 @@ import TileImage from './TileImage.js'; import {appendParams} from '../uri.js'; -import {assign} from '../obj.js'; import {createEmpty} from '../extent.js'; import {modulo} from '../math.js'; import {scale as scaleSize, toSize} from '../size.js'; @@ -208,7 +207,7 @@ class TileArcGISRest extends TileImage { * @api */ updateParams(params) { - assign(this.params_, params); + Object.assign(this.params_, params); this.setKey(this.getKeyForParams_()); } @@ -246,7 +245,7 @@ class TileArcGISRest extends TileImage { 'FORMAT': 'PNG32', 'TRANSPARENT': true, }; - assign(baseParams, this.params_); + Object.assign(baseParams, this.params_); return this.getRequestUrl_( tileCoord, diff --git a/src/ol/source/TileWMS.js b/src/ol/source/TileWMS.js index aa10cc83c5..82ea2cdfa1 100644 --- a/src/ol/source/TileWMS.js +++ b/src/ol/source/TileWMS.js @@ -6,7 +6,6 @@ import TileImage from './TileImage.js'; import {DEFAULT_VERSION} from './wms.js'; import {appendParams} from '../uri.js'; import {assert} from '../asserts.js'; -import {assign} from '../obj.js'; import {buffer, createEmpty} from '../extent.js'; import {buffer as bufferSize, scale as scaleSize, toSize} from '../size.js'; import {calculateSourceResolution} from '../reproj.js'; @@ -218,7 +217,7 @@ class TileWMS extends TileImage { 'TRANSPARENT': true, 'QUERY_LAYERS': this.params_['LAYERS'], }; - assign(baseParams, this.params_, params); + Object.assign(baseParams, this.params_, params); const x = Math.floor((coordinate[0] - tileExtent[0]) / tileResolution); const y = Math.floor((tileExtent[3] - coordinate[1]) / tileResolution); @@ -279,7 +278,7 @@ class TileWMS extends TileImage { baseParams['SCALE'] = (resolution * mpu) / pixelSize; } - assign(baseParams, params); + Object.assign(baseParams, params); return appendParams(/** @type {string} */ (this.urls[0]), baseParams); } @@ -407,7 +406,7 @@ class TileWMS extends TileImage { * @api */ updateParams(params) { - assign(this.params_, params); + Object.assign(this.params_, params); this.updateV13_(); this.setKey(this.getKeyForParams_()); } @@ -462,7 +461,7 @@ class TileWMS extends TileImage { 'FORMAT': 'image/png', 'TRANSPARENT': true, }; - assign(baseParams, this.params_); + Object.assign(baseParams, this.params_); return this.getRequestUrl_( tileCoord, diff --git a/src/ol/source/WMTS.js b/src/ol/source/WMTS.js index a9f2322d5f..a43d7ab542 100644 --- a/src/ol/source/WMTS.js +++ b/src/ol/source/WMTS.js @@ -4,7 +4,6 @@ import TileImage from './TileImage.js'; import {appendParams} from '../uri.js'; -import {assign} from '../obj.js'; import {containsExtent} from '../extent.js'; import {createFromCapabilitiesMatrixSet} from '../tilegrid/WMTS.js'; import {createFromTileUrlFunctions, expandUrl} from '../tileurlfunction.js'; @@ -267,7 +266,7 @@ class WMTS extends TileImage { * @api */ updateDimensions(dimensions) { - assign(this.dimensions_, dimensions); + Object.assign(this.dimensions_, dimensions); this.setKey(this.getKeyForDimensions_()); } @@ -287,7 +286,7 @@ class WMTS extends TileImage { }; if (requestEncoding == 'KVP') { - assign(context, { + Object.assign(context, { 'Service': 'WMTS', 'Request': 'GetTile', 'Version': this.version_, @@ -327,7 +326,7 @@ class WMTS extends TileImage { 'TileCol': tileCoord[1], 'TileRow': tileCoord[2], }; - assign(localContext, dimensions); + Object.assign(localContext, dimensions); let url = template; if (requestEncoding == 'KVP') { url = appendParams(url, localContext); diff --git a/src/ol/source/ogcTileUtil.js b/src/ol/source/ogcTileUtil.js index 1cc0cf7071..2925218236 100644 --- a/src/ol/source/ogcTileUtil.js +++ b/src/ol/source/ogcTileUtil.js @@ -3,7 +3,6 @@ */ import TileGrid from '../tilegrid/TileGrid.js'; -import {assign} from '../obj.js'; import {getJSON, resolveUrl} from '../net.js'; import {get as getProjection} from '../proj.js'; import {getIntersection as intersectExtents} from '../extent.js'; @@ -324,7 +323,7 @@ function parseTileMatrixSet( } } - assign(localContext, context); + Object.assign(localContext, context); const url = tileUrlTemplate.replace(/\{(\w+?)\}/g, function (m, p) { return localContext[p]; diff --git a/src/ol/webgl.js b/src/ol/webgl.js index 6e9acb6a61..63ecad982c 100644 --- a/src/ol/webgl.js +++ b/src/ol/webgl.js @@ -3,7 +3,6 @@ */ import {SAFARI_BUG_237906} from './has.js'; -import {assign} from './obj.js'; /** * Constants taken from goog.webgl @@ -92,7 +91,7 @@ const CONTEXT_IDS = ['experimental-webgl', 'webgl', 'webkit-3d', 'moz-webgl']; * @return {WebGLRenderingContext} WebGL rendering context. */ export function getContext(canvas, opt_attributes) { - const attributes = assign( + const attributes = Object.assign( { preserveDrawingBuffer: true, antialias: SAFARI_BUG_237906 ? false : true, // https://bugs.webkit.org/show_bug.cgi?id=237906 diff --git a/src/ol/worker/webgl.js b/src/ol/worker/webgl.js index 34cb5509f5..cee529e6af 100644 --- a/src/ol/worker/webgl.js +++ b/src/ol/worker/webgl.js @@ -3,7 +3,6 @@ * @module ol/worker/webgl */ import {WebGLWorkerMessageType} from '../render/webgl/constants.js'; -import {assign} from '../obj.js'; import { create as createTransform, makeInverse as makeInverseTransform, @@ -49,7 +48,7 @@ worker.onmessage = (event) => { } /** @type {import('../render/webgl/constants.js').WebGLWorkerGenerateBuffersMessage} */ - const message = assign( + const message = Object.assign( { vertexBuffer: vertexBuffer.buffer, indexBuffer: indexBuffer.buffer, @@ -116,7 +115,7 @@ worker.onmessage = (event) => { const vertexBuffer = Float32Array.from(vertices); /** @type {import('../render/webgl/constants.js').WebGLWorkerGenerateBuffersMessage} */ - const message = assign( + const message = Object.assign( { vertexBuffer: vertexBuffer.buffer, indexBuffer: indexBuffer.buffer, @@ -154,7 +153,7 @@ worker.onmessage = (event) => { const vertexBuffer = Float32Array.from(vertices); /** @type {import('../render/webgl/constants.js').WebGLWorkerGenerateBuffersMessage} */ - const message = assign( + const message = Object.assign( { vertexBuffer: vertexBuffer.buffer, indexBuffer: indexBuffer.buffer, diff --git a/test/browser/spec/ol/layer/Group.test.js b/test/browser/spec/ol/layer/Group.test.js index ba361f4f43..1aae406041 100644 --- a/test/browser/spec/ol/layer/Group.test.js +++ b/test/browser/spec/ol/layer/Group.test.js @@ -2,7 +2,6 @@ import Collection from '../../../../../src/ol/Collection.js'; import Layer from '../../../../../src/ol/layer/Layer.js'; import LayerGroup from '../../../../../src/ol/layer/Group.js'; import Source from '../../../../../src/ol/source/Source.js'; -import {assign} from '../../../../../src/ol/obj.js'; import {getIntersection} from '../../../../../src/ol/extent.js'; import {getUid} from '../../../../../src/ol/util.js'; @@ -531,9 +530,9 @@ describe('ol/layer/Group', function () { expect(layerStatesArray[0]).to.eql(layer1.getLayerState()); // layer state should match except for layer reference - const layerState = assign({}, layerStatesArray[0]); + const layerState = Object.assign({}, layerStatesArray[0]); delete layerState.layer; - const groupState = assign({}, group.getLayerState()); + const groupState = Object.assign({}, group.getLayerState()); delete groupState.layer; expect(layerState).to.eql(groupState); @@ -580,14 +579,14 @@ describe('ol/layer/Group', function () { // compare layer state to group state // layer state should match except for layer reference - let layerState = assign({}, layerStatesArray[0]); + let layerState = Object.assign({}, layerStatesArray[0]); delete layerState.layer; - const groupState = assign({}, group.getLayerState()); + const groupState = Object.assign({}, group.getLayerState()); delete groupState.layer; expect(layerState).to.eql(groupState); // layer state should be transformed (and we ignore layer reference) - layerState = assign({}, layerStatesArray[1]); + layerState = Object.assign({}, layerStatesArray[1]); delete layerState.layer; expect(layerState).to.eql({ opacity: 0.25, diff --git a/test/node/ol/obj.test.js b/test/node/ol/obj.test.js index 5ae997553e..bcd7449f0c 100644 --- a/test/node/ol/obj.test.js +++ b/test/node/ol/obj.test.js @@ -1,45 +1,7 @@ import expect from '../expect.js'; -import {assign, clear, isEmpty} from '../../../src/ol/obj.js'; +import {clear, isEmpty} from '../../../src/ol/obj.js'; describe('ol/obj.js', () => { - describe('assign()', function () { - it('is an alias for Object.assign() where available', function () { - if (typeof Object.assign === 'function') { - expect(assign).to.be(Object.assign); - } - }); - - it('assigns properties from a source object to a target object', function () { - const source = { - sourceProp1: 'sourceValue1', - sourceProp2: 'sourceValue2', - }; - - const target = { - sourceProp1: 'overridden', - targetProp1: 'targetValue1', - }; - - const assigned = assign(target, source); - expect(assigned).to.be(target); - expect(assigned.sourceProp1).to.be('sourceValue1'); - expect(assigned.sourceProp2).to.be('sourceValue2'); - expect(assigned.targetProp1).to.be('targetValue1'); - }); - - it('throws a TypeError with `undefined` as target', function () { - expect(() => assign()).to.throwException( - /Cannot convert undefined or null to object/ - ); - }); - - it('throws a TypeError with `null` as target', function () { - expect(() => assign(null)).to.throwException( - /Cannot convert undefined or null to object/ - ); - }); - }); - describe('clear()', function () { it('removes all properties from an object', function () { expect(isEmpty(clear({foo: 'bar'}))).to.be(true);