clone the params option

This commit is contained in:
mike-000
2022-08-24 11:36:42 +01:00
parent 08ad881d5e
commit d74379a7d9
5 changed files with 8 additions and 4 deletions

View File

@@ -6,6 +6,10 @@
Future versions will no longer throw `ol/AssertionError` with an error `code`. Instead, they will throw `Error` with just the error message.
#### Updating parameters in `ol/source/ImageWMS` and `ol/source/TileWMS`
The `updateParams()` method will be the only way to update parameters. Changes made directly to the `params` object passed as a constructor option will have no effect.
### 7.0.0
#### Removal of deprecated properties and methods

View File

@@ -106,7 +106,7 @@ class ImageWMS extends ImageSource {
* @private
* @type {!Object}
*/
this.params_ = options.params || {};
this.params_ = Object.assign({}, options.params);
/**
* @private

View File

@@ -84,7 +84,7 @@ class TileWMS extends TileImage {
constructor(options) {
options = options ? options : /** @type {Options} */ ({});
const params = options.params || {};
const params = Object.assign({}, options.params);
const transparent = 'TRANSPARENT' in params ? params['TRANSPARENT'] : true;

View File

@@ -206,8 +206,8 @@ describe('ol/source/ImageWMS', function () {
it('extends FORMAT_OPTIONS if it is already present', function () {
options.serverType = 'geoserver';
const source = new ImageWMS(options);
options.params.FORMAT_OPTIONS = 'param1:value1';
const source = new ImageWMS(options);
pixelRatio = 2;
const image = source.getImage(extent, resolution, pixelRatio, projection);
const uri = new URL(image.src_);

View File

@@ -150,8 +150,8 @@ describe('ol/source/TileWMS', function () {
it('extends FORMAT_OPTIONS if it is already present', function () {
options.serverType = 'geoserver';
const source = new TileWMS(options);
options.params.FORMAT_OPTIONS = 'param1:value1';
const source = new TileWMS(options);
const tile = source.getTile(3, 2, 2, 2, getProjection('CRS:84'));
const uri = new URL(tile.src_);
const queryData = uri.searchParams;