Merge pull request #10244 from ahocevar/no-multi-assign

Update to new eslint config with no-multi-assign
This commit is contained in:
Andreas Hocevar
2019-11-02 16:48:46 +01:00
committed by GitHub
36 changed files with 191 additions and 102 deletions

46
package-lock.json generated
View File

@@ -3636,12 +3636,12 @@
} }
}, },
"eslint-config-openlayers": { "eslint-config-openlayers": {
"version": "12.0.0", "version": "13.0.0",
"resolved": "https://registry.npmjs.org/eslint-config-openlayers/-/eslint-config-openlayers-12.0.0.tgz", "resolved": "https://registry.npmjs.org/eslint-config-openlayers/-/eslint-config-openlayers-13.0.0.tgz",
"integrity": "sha512-cln+A0qoBvf9ZTVFt9UJ1pTb+TfKOZ5B55jPtYrIcREKXsRycTtWNQjtHQJRbfTPp8CGoU6tjJ6yLUsseVgv0Q==", "integrity": "sha512-FlhPbUhrgh9nyIrcf6jX8cZHLOxl2Z4rmLnMrhwBhE+KQK2n3hywXpkNvUROWV9TQpxavzaA7punYHL4ggUpig==",
"dev": true, "dev": true,
"requires": { "requires": {
"eslint-plugin-import": "^2.17.3" "eslint-plugin-import": "^2.18.2"
} }
}, },
"eslint-import-resolver-node": { "eslint-import-resolver-node": {
@@ -3672,9 +3672,9 @@
} }
}, },
"eslint-module-utils": { "eslint-module-utils": {
"version": "2.4.0", "version": "2.4.1",
"resolved": "https://registry.npmjs.org/eslint-module-utils/-/eslint-module-utils-2.4.0.tgz", "resolved": "https://registry.npmjs.org/eslint-module-utils/-/eslint-module-utils-2.4.1.tgz",
"integrity": "sha512-14tltLm38Eu3zS+mt0KvILC3q8jyIAH518MlG+HO0p+yK885Lb1UHTY/UgR91eOyGdmxAPb+OLoW4znqIT6Ndw==", "integrity": "sha512-H6DOj+ejw7Tesdgbfs4jeS4YMFrT8uI8xwd1gtQqXssaR0EQ26L+2O/w6wkYFy2MymON0fTwHmXBvvfLNZVZEw==",
"dev": true, "dev": true,
"requires": { "requires": {
"debug": "^2.6.8", "debug": "^2.6.8",
@@ -3751,9 +3751,9 @@
} }
}, },
"eslint-plugin-import": { "eslint-plugin-import": {
"version": "2.17.3", "version": "2.18.2",
"resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.17.3.tgz", "resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.18.2.tgz",
"integrity": "sha512-qeVf/UwXFJbeyLbxuY8RgqDyEKCkqV7YC+E5S5uOjAp4tOc8zj01JP3ucoBM8JcEqd1qRasJSg6LLlisirfy0Q==", "integrity": "sha512-5ohpsHAiUBRNaBWAF08izwUGlbrJoJJ+W9/TBwsGoR1MnlgfwMIKrFeSjWbt6moabiXW9xNvtFz+97KHRfI4HQ==",
"dev": true, "dev": true,
"requires": { "requires": {
"array-includes": "^3.0.3", "array-includes": "^3.0.3",
@@ -3763,8 +3763,8 @@
"eslint-import-resolver-node": "^0.3.2", "eslint-import-resolver-node": "^0.3.2",
"eslint-module-utils": "^2.4.0", "eslint-module-utils": "^2.4.0",
"has": "^1.0.3", "has": "^1.0.3",
"lodash": "^4.17.11",
"minimatch": "^3.0.4", "minimatch": "^3.0.4",
"object.values": "^1.1.0",
"read-pkg-up": "^2.0.0", "read-pkg-up": "^2.0.0",
"resolve": "^1.11.0" "resolve": "^1.11.0"
}, },
@@ -3795,9 +3795,9 @@
"dev": true "dev": true
}, },
"resolve": { "resolve": {
"version": "1.11.0", "version": "1.12.0",
"resolved": "https://registry.npmjs.org/resolve/-/resolve-1.11.0.tgz", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.12.0.tgz",
"integrity": "sha512-WL2pBDjqT6pGUNSUzMw00o4T7If+z4H2x3Gz893WoUQ5KW8Vr9txp00ykiP16VBaZF5+j/OcXJHZ9+PCvdiDKw==", "integrity": "sha512-B/dOmuoAik5bKcD6s6nXDCjzUKnaDvdkRyAk6rsmsKLipWj4797iothd7jmmUhWTfinVMU+wc56rYKsit2Qy4w==",
"dev": true, "dev": true,
"requires": { "requires": {
"path-parse": "^1.0.6" "path-parse": "^1.0.6"
@@ -5767,9 +5767,9 @@
"dev": true "dev": true
}, },
"https-proxy-agent": { "https-proxy-agent": {
"version": "2.2.2", "version": "2.2.4",
"resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-2.2.2.tgz", "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-2.2.4.tgz",
"integrity": "sha512-c8Ndjc9Bkpfx/vCJueCPy0jlP4ccCCSNDp8xwCZzPjKJUm+B+u9WX2x98Qx4n1PiMNTWo3D7KK5ifNV/yJyRzg==", "integrity": "sha512-OmvfoQ53WLjtA9HeYP9RNrWMJzzAz1JGaSFr1nijg0PVR1JaD/xbJq1mdEIIlxGpXp9eSe/O2LgU9DJmTPd0Eg==",
"dev": true, "dev": true,
"requires": { "requires": {
"agent-base": "^4.3.0", "agent-base": "^4.3.0",
@@ -8013,6 +8013,18 @@
"isobject": "^3.0.1" "isobject": "^3.0.1"
} }
}, },
"object.values": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/object.values/-/object.values-1.1.0.tgz",
"integrity": "sha512-8mf0nKLAoFX6VlNVdhGj31SVYpaNFtUnuoOXWyFEstsWRgU837AK+JYM0iAxwkSzGRbwn8cbFmgbyxj1j4VbXg==",
"dev": true,
"requires": {
"define-properties": "^1.1.3",
"es-abstract": "^1.12.0",
"function-bind": "^1.1.1",
"has": "^1.0.3"
}
},
"obuf": { "obuf": {
"version": "1.1.2", "version": "1.1.2",
"resolved": "https://registry.npmjs.org/obuf/-/obuf-1.1.2.tgz", "resolved": "https://registry.npmjs.org/obuf/-/obuf-1.1.2.tgz",

View File

@@ -57,7 +57,7 @@
"copy-webpack-plugin": "^5.0.4", "copy-webpack-plugin": "^5.0.4",
"coveralls": "3.0.7", "coveralls": "3.0.7",
"eslint": "^6.0.0", "eslint": "^6.0.0",
"eslint-config-openlayers": "^12.0.0", "eslint-config-openlayers": "^13.0.0",
"expect.js": "0.3.1", "expect.js": "0.3.1",
"front-matter": "^3.0.2", "front-matter": "^3.0.2",
"fs-extra": "^8.0.0", "fs-extra": "^8.0.0",

View File

@@ -512,15 +512,18 @@ class Overlay extends BaseObject {
positioning == OverlayPositioning.CENTER_RIGHT || positioning == OverlayPositioning.CENTER_RIGHT ||
positioning == OverlayPositioning.TOP_RIGHT) { positioning == OverlayPositioning.TOP_RIGHT) {
if (this.rendered.left_ !== '') { if (this.rendered.left_ !== '') {
this.rendered.left_ = style.left = ''; this.rendered.left_ = '';
style.left = '';
} }
const right = Math.round(mapSize[0] - pixel[0] - offsetX) + 'px'; const right = Math.round(mapSize[0] - pixel[0] - offsetX) + 'px';
if (this.rendered.right_ != right) { if (this.rendered.right_ != right) {
this.rendered.right_ = style.right = right; this.rendered.right_ = right;
style.right = right;
} }
} else { } else {
if (this.rendered.right_ !== '') { if (this.rendered.right_ !== '') {
this.rendered.right_ = style.right = ''; this.rendered.right_ = '';
style.right = '';
} }
if (positioning == OverlayPositioning.BOTTOM_CENTER || if (positioning == OverlayPositioning.BOTTOM_CENTER ||
positioning == OverlayPositioning.CENTER_CENTER || positioning == OverlayPositioning.CENTER_CENTER ||
@@ -529,22 +532,26 @@ class Overlay extends BaseObject {
} }
const left = Math.round(pixel[0] + offsetX) + 'px'; const left = Math.round(pixel[0] + offsetX) + 'px';
if (this.rendered.left_ != left) { if (this.rendered.left_ != left) {
this.rendered.left_ = style.left = left; this.rendered.left_ = left;
style.left = left;
} }
} }
if (positioning == OverlayPositioning.BOTTOM_LEFT || if (positioning == OverlayPositioning.BOTTOM_LEFT ||
positioning == OverlayPositioning.BOTTOM_CENTER || positioning == OverlayPositioning.BOTTOM_CENTER ||
positioning == OverlayPositioning.BOTTOM_RIGHT) { positioning == OverlayPositioning.BOTTOM_RIGHT) {
if (this.rendered.top_ !== '') { if (this.rendered.top_ !== '') {
this.rendered.top_ = style.top = ''; this.rendered.top_ = '';
style.top = '';
} }
const bottom = Math.round(mapSize[1] - pixel[1] - offsetY) + 'px'; const bottom = Math.round(mapSize[1] - pixel[1] - offsetY) + 'px';
if (this.rendered.bottom_ != bottom) { if (this.rendered.bottom_ != bottom) {
this.rendered.bottom_ = style.bottom = bottom; this.rendered.bottom_ = bottom;
style.bottom = bottom;
} }
} else { } else {
if (this.rendered.bottom_ !== '') { if (this.rendered.bottom_ !== '') {
this.rendered.bottom_ = style.bottom = ''; this.rendered.bottom_ = '';
style.bottom = '';
} }
if (positioning == OverlayPositioning.CENTER_LEFT || if (positioning == OverlayPositioning.CENTER_LEFT ||
positioning == OverlayPositioning.CENTER_CENTER || positioning == OverlayPositioning.CENTER_CENTER ||
@@ -553,7 +560,8 @@ class Overlay extends BaseObject {
} }
const top = Math.round(pixel[1] + offsetY) + 'px'; const top = Math.round(pixel[1] + offsetY) + 'px';
if (this.rendered.top_ != top) { if (this.rendered.top_ != top) {
this.rendered.top_ = style.top = top; this.rendered.top_ = 'top';
style.top = top;
} }
} }
} }

View File

@@ -124,7 +124,8 @@ class VectorRenderTile extends Tile {
this.removeSourceTiles_(this); this.removeSourceTiles_(this);
for (const key in this.context_) { for (const key in this.context_) {
const canvas = this.context_[key].canvas; const canvas = this.context_[key].canvas;
canvas.width = canvas.height = 0; canvas.width = 0;
canvas.height = 0;
} }
for (const key in this.executorGroups) { for (const key in this.executorGroups) {
const executorGroups = this.executorGroups[key]; const executorGroups = this.executorGroups[key];

View File

@@ -37,10 +37,12 @@ export function createExtent(extent, onlyCenter, smooth) {
// note: when zooming out of bounds, min and max values for x and y may // note: when zooming out of bounds, min and max values for x and y may
// end up inverted (min > max); this has to be accounted for // end up inverted (min > max); this has to be accounted for
if (minX > maxX) { if (minX > maxX) {
minX = maxX = (maxX + minX) / 2; minX = (maxX + minX) / 2;
maxX = minX;
} }
if (minY > maxY) { if (minY > maxY) {
minY = maxY = (maxY + minY) / 2; minY = (maxY + minY) / 2;
maxY = minY;
} }
let x = clamp(center[0], minX, maxX); let x = clamp(center[0], minX, maxX);

View File

@@ -72,7 +72,8 @@ class Target extends Disposable {
} }
let listeners = this.listeners_[type]; let listeners = this.listeners_[type];
if (!listeners) { if (!listeners) {
listeners = this.listeners_[type] = []; listeners = [];
this.listeners_[type] = listeners;
} }
if (listeners.indexOf(listener) === -1) { if (listeners.indexOf(listener) === -1) {
listeners.push(listener); listeners.push(listener);

View File

@@ -1777,7 +1777,9 @@ function setCommonGeometryProperties(multiGeometry, geometries) {
const tessellates = new Array(geometries.length); const tessellates = new Array(geometries.length);
const altitudeModes = new Array(geometries.length); const altitudeModes = new Array(geometries.length);
let hasExtrude, hasTessellate, hasAltitudeMode; let hasExtrude, hasTessellate, hasAltitudeMode;
hasExtrude = hasTessellate = hasAltitudeMode = false; hasExtrude = false;
hasTessellate = false;
hasAltitudeMode = false;
for (let i = 0; i < ii; ++i) { for (let i = 0; i < ii; ++i) {
const geometry = geometries[i]; const geometry = geometries[i];
extrudes[i] = geometry.get('extrude'); extrudes[i] = geometry.get('extrude');

View File

@@ -654,7 +654,8 @@ class Modify extends PointerInteraction {
}; };
const featureSegments = [centerSegmentData, circumferenceSegmentData]; const featureSegments = [centerSegmentData, circumferenceSegmentData];
centerSegmentData.featureSegments = circumferenceSegmentData.featureSegments = featureSegments; centerSegmentData.featureSegments = featureSegments;
circumferenceSegmentData.featureSegments = featureSegments;
this.rBush_.insert(createExtent(coordinates), centerSegmentData); this.rBush_.insert(createExtent(coordinates), centerSegmentData);
this.rBush_.insert(geometry.getExtent(), circumferenceSegmentData); this.rBush_.insert(geometry.getExtent(), circumferenceSegmentData);
} }
@@ -746,12 +747,14 @@ class Modify extends PointerInteraction {
switch (geometry.getType()) { switch (geometry.getType()) {
case GeometryType.POINT: case GeometryType.POINT:
coordinates = vertex; coordinates = vertex;
segment[0] = segment[1] = vertex; segment[0] = vertex;
segment[1] = vertex;
break; break;
case GeometryType.MULTI_POINT: case GeometryType.MULTI_POINT:
coordinates = geometry.getCoordinates(); coordinates = geometry.getCoordinates();
coordinates[segmentData.index] = vertex; coordinates[segmentData.index] = vertex;
segment[0] = segment[1] = vertex; segment[0] = vertex;
segment[1] = vertex;
break; break;
case GeometryType.LINE_STRING: case GeometryType.LINE_STRING:
coordinates = geometry.getCoordinates(); coordinates = geometry.getCoordinates();
@@ -774,7 +777,8 @@ class Modify extends PointerInteraction {
segment[index] = vertex; segment[index] = vertex;
break; break;
case GeometryType.CIRCLE: case GeometryType.CIRCLE:
segment[0] = segment[1] = vertex; segment[0] = vertex;
segment[1] = vertex;
if (segmentData.index === CIRCLE_CENTER_INDEX) { if (segmentData.index === CIRCLE_CENTER_INDEX) {
this.changingFeature_ = true; this.changingFeature_ = true;
geometry.setCenter(vertex); geometry.setCenter(vertex);
@@ -889,8 +893,10 @@ class Modify extends PointerInteraction {
const coordinates = geometry.getCenter(); const coordinates = geometry.getCenter();
const centerSegmentData = segmentData.featureSegments[0]; const centerSegmentData = segmentData.featureSegments[0];
const circumferenceSegmentData = segmentData.featureSegments[1]; const circumferenceSegmentData = segmentData.featureSegments[1];
centerSegmentData.segment[0] = centerSegmentData.segment[1] = coordinates; centerSegmentData.segment[0] = coordinates;
circumferenceSegmentData.segment[0] = circumferenceSegmentData.segment[1] = coordinates; centerSegmentData.segment[1] = coordinates;
circumferenceSegmentData.segment[0] = coordinates;
circumferenceSegmentData.segment[1] = coordinates;
this.rBush_.update(createExtent(coordinates), centerSegmentData); this.rBush_.update(createExtent(coordinates), centerSegmentData);
this.rBush_.update(geometry.getExtent(), circumferenceSegmentData); this.rBush_.update(geometry.getExtent(), circumferenceSegmentData);
} else { } else {

View File

@@ -198,7 +198,7 @@ class Translate extends PointerInteraction {
handleDownEvent(event) { handleDownEvent(event) {
this.lastFeature_ = this.featuresAtPixel_(event.pixel, event.map); this.lastFeature_ = this.featuresAtPixel_(event.pixel, event.map);
if (!this.lastCoordinate_ && this.lastFeature_) { if (!this.lastCoordinate_ && this.lastFeature_) {
this.startCoordinate_ = this.startCoordinate_ = event.coordinate;
this.lastCoordinate_ = event.coordinate; this.lastCoordinate_ = event.coordinate;
this.handleMoveEvent(event); this.handleMoveEvent(event);

View File

@@ -581,7 +581,8 @@ class Graticule extends VectorLayer {
createGraticule_(extent, center, resolution, squaredTolerance) { createGraticule_(extent, center, resolution, squaredTolerance) {
const interval = this.getInterval_(resolution); const interval = this.getInterval_(resolution);
if (interval == -1) { if (interval == -1) {
this.meridians_.length = this.parallels_.length = 0; this.meridians_.length = 0;
this.parallels_.length = 0;
if (this.meridiansLabels_) { if (this.meridiansLabels_) {
this.meridiansLabels_.length = 0; this.meridiansLabels_.length = 0;
} }
@@ -708,7 +709,8 @@ class Graticule extends VectorLayer {
const flatCoordinates = meridian(lon, minLat, maxLat, this.projection_, squaredTolerance); const flatCoordinates = meridian(lon, minLat, maxLat, this.projection_, squaredTolerance);
let lineString = this.meridians_[index]; let lineString = this.meridians_[index];
if (!lineString) { if (!lineString) {
lineString = this.meridians_[index] = new LineString(flatCoordinates, GeometryLayout.XY); lineString = new LineString(flatCoordinates, GeometryLayout.XY);
this.meridians_[index] = lineString;
} else { } else {
lineString.setFlatCoordinates(GeometryLayout.XY, flatCoordinates); lineString.setFlatCoordinates(GeometryLayout.XY, flatCoordinates);
lineString.changed(); lineString.changed();

View File

@@ -74,7 +74,10 @@ class RenderBox extends Disposable {
if (this.map_) { if (this.map_) {
this.map_.getOverlayContainer().removeChild(this.element_); this.map_.getOverlayContainer().removeChild(this.element_);
const style = this.element_.style; const style = this.element_.style;
style.left = style.top = style.width = style.height = 'inherit'; style.left = 'inherit';
style.top = 'inherit';
style.width = 'inherit';
style.height = 'inherit';
} }
this.map_ = map; this.map_ = map;
if (this.map_) { if (this.map_) {

View File

@@ -268,10 +268,10 @@ class RenderFeature {
/** /**
* @return {Array<number>|Array<Array<number>>} Ends or endss. * @return {Array<number>|Array<Array<number>>} Ends or endss.
*/ */
RenderFeature.prototype.getEnds = RenderFeature.prototype.getEnds = function() {
RenderFeature.prototype.getEndss = function() {
return this.ends_; return this.ends_;
}; };
RenderFeature.prototype.getEndss = RenderFeature.prototype.getEnds;
/** /**

View File

@@ -311,13 +311,15 @@ export const measureTextHeight = (function() {
if (!div) { if (!div) {
div = document.createElement('div'); div = document.createElement('div');
div.innerHTML = 'M'; div.innerHTML = 'M';
div.style.margin = div.style.padding = '0 !important'; div.style.margin = '0 !important';
div.style.padding = '0 !important';
div.style.position = 'absolute !important'; div.style.position = 'absolute !important';
div.style.left = '-99999px !important'; div.style.left = '-99999px !important';
} }
div.style.font = font; div.style.font = font;
document.body.appendChild(div); document.body.appendChild(div);
height = heights[font] = div.offsetHeight; height = div.offsetHeight;
heights[font] = height;
document.body.removeChild(div); document.body.removeChild(div);
} }
return height; return height;
@@ -351,7 +353,8 @@ export function measureAndCacheTextWidth(font, text, cache) {
if (text in cache) { if (text in cache) {
return cache[text]; return cache[text];
} }
const width = cache[text] = measureTextWidth(font, text); const width = measureTextWidth(font, text);
cache[text] = width;
return width; return width;
} }

View File

@@ -87,7 +87,8 @@ class BuilderGroup {
declutter = this.declutterGroups_; declutter = this.declutterGroups_;
/** @type {number} */ (declutter[0][4])++; /** @type {number} */ (declutter[0][4])++;
} else { } else {
declutter = this.declutterGroups_ = [createEmpty()]; declutter = [createEmpty()];
this.declutterGroups_ = declutter;
declutter[0].push(1); declutter[0].push(1);
} }
} }

View File

@@ -315,10 +315,14 @@ class Executor extends Disposable {
const boxY = y - padding[0]; const boxY = y - padding[0];
if (fillStroke || rotation !== 0) { if (fillStroke || rotation !== 0) {
p1[0] = p4[0] = boxX; p1[0] = boxX;
p1[1] = p2[1] = boxY; p4[0] = boxX;
p2[0] = p3[0] = boxX + boxW; p1[1] = boxY;
p3[1] = p4[1] = boxY + boxH; p2[1] = boxY;
p2[0] = boxX + boxW;
p3[0] = p2[0];
p3[1] = boxY + boxH;
p4[1] = p3[1];
} }
let transform = null; let transform = null;
@@ -576,7 +580,8 @@ class Executor extends Disposable {
} }
if (!pendingFill && !pendingStroke) { if (!pendingFill && !pendingStroke) {
context.beginPath(); context.beginPath();
prevX = prevY = NaN; prevX = NaN;
prevY = NaN;
} }
++i; ++i;
break; break;
@@ -644,13 +649,18 @@ class Executor extends Disposable {
strokeKey = /** @type {string} */ (instruction[20]); strokeKey = /** @type {string} */ (instruction[20]);
fillKey = /** @type {string} */ (instruction[21]); fillKey = /** @type {string} */ (instruction[21]);
const labelWithAnchor = this.drawTextImageWithPointPlacement_(text, textKey, strokeKey, fillKey); const labelWithAnchor = this.drawTextImageWithPointPlacement_(text, textKey, strokeKey, fillKey);
image = instruction[3] = labelWithAnchor.label; image = labelWithAnchor.label;
instruction[3] = image;
const textOffsetX = /** @type {number} */ (instruction[22]); const textOffsetX = /** @type {number} */ (instruction[22]);
anchorX = instruction[4] = (labelWithAnchor.anchorX - textOffsetX) * this.pixelRatio; anchorX = (labelWithAnchor.anchorX - textOffsetX) * this.pixelRatio;
instruction[4] = anchorX;
const textOffsetY = /** @type {number} */ (instruction[23]); const textOffsetY = /** @type {number} */ (instruction[23]);
anchorY = instruction[5] = (labelWithAnchor.anchorY - textOffsetY) * this.pixelRatio; anchorY = (labelWithAnchor.anchorY - textOffsetY) * this.pixelRatio;
height = instruction[7] = image.height; instruction[5] = anchorY;
width = instruction[14] = image.width; height = image.height;
instruction[7] = height;
width = image.width;
instruction[14] = width;
} }
let geometryWidths; let geometryWidths;
@@ -665,7 +675,8 @@ class Executor extends Disposable {
backgroundStroke = /** @type {boolean} */ (instruction[17]); backgroundStroke = /** @type {boolean} */ (instruction[17]);
} else { } else {
padding = defaultPadding; padding = defaultPadding;
backgroundFill = backgroundStroke = false; backgroundFill = false;
backgroundStroke = false;
} }
if (rotateWithView && viewRotationFromTransform) { if (rotateWithView && viewRotationFromTransform) {
@@ -730,7 +741,8 @@ class Executor extends Disposable {
if (font in this.widths_) { if (font in this.widths_) {
cachedWidths = this.widths_[font]; cachedWidths = this.widths_[font];
} else { } else {
cachedWidths = this.widths_[font] = {}; cachedWidths = {};
this.widths_[font] = cachedWidths;
} }
const pathLength = lineStringLength(pixelCoordinates, begin, end, 2); const pathLength = lineStringLength(pixelCoordinates, begin, end, 2);

View File

@@ -116,7 +116,8 @@ class ExecutorGroup extends Disposable {
for (const zIndex in allInstructions) { for (const zIndex in allInstructions) {
let executors = this.executorsByZIndex_[zIndex]; let executors = this.executorsByZIndex_[zIndex];
if (executors === undefined) { if (executors === undefined) {
this.executorsByZIndex_[zIndex] = executors = {}; executors = {};
this.executorsByZIndex_[zIndex] = executors;
} }
const instructionByZindex = allInstructions[zIndex]; const instructionByZindex = allInstructions[zIndex];
for (const builderType in instructionByZindex) { for (const builderType in instructionByZindex) {
@@ -139,7 +140,8 @@ class ExecutorGroup extends Disposable {
} }
if (this.hitDetectionContext_) { if (this.hitDetectionContext_) {
const canvas = this.hitDetectionContext_.canvas; const canvas = this.hitDetectionContext_.canvas;
canvas.width = canvas.height = 0; canvas.width = 0;
canvas.height = 0;
} }
super.disposeInternal(); super.disposeInternal();

View File

@@ -719,7 +719,8 @@ class CanvasImmediateRenderer extends VectorContext {
}; };
} else { } else {
if (contextFillState.fillStyle != fillState.fillStyle) { if (contextFillState.fillStyle != fillState.fillStyle) {
contextFillState.fillStyle = context.fillStyle = fillState.fillStyle; contextFillState.fillStyle = fillState.fillStyle;
context.fillStyle = fillState.fillStyle;
} }
} }
} }
@@ -752,30 +753,33 @@ class CanvasImmediateRenderer extends VectorContext {
}; };
} else { } else {
if (contextStrokeState.lineCap != strokeState.lineCap) { if (contextStrokeState.lineCap != strokeState.lineCap) {
contextStrokeState.lineCap = context.lineCap = strokeState.lineCap; contextStrokeState.lineCap = strokeState.lineCap;
context.lineCap = strokeState.lineCap;
} }
if (context.setLineDash) { if (context.setLineDash) {
if (!equals(contextStrokeState.lineDash, strokeState.lineDash)) { if (!equals(contextStrokeState.lineDash, strokeState.lineDash)) {
context.setLineDash(contextStrokeState.lineDash = strokeState.lineDash); context.setLineDash(contextStrokeState.lineDash = strokeState.lineDash);
} }
if (contextStrokeState.lineDashOffset != strokeState.lineDashOffset) { if (contextStrokeState.lineDashOffset != strokeState.lineDashOffset) {
contextStrokeState.lineDashOffset = context.lineDashOffset = contextStrokeState.lineDashOffset = strokeState.lineDashOffset;
strokeState.lineDashOffset; context.lineDashOffset = strokeState.lineDashOffset;
} }
} }
if (contextStrokeState.lineJoin != strokeState.lineJoin) { if (contextStrokeState.lineJoin != strokeState.lineJoin) {
contextStrokeState.lineJoin = context.lineJoin = strokeState.lineJoin; contextStrokeState.lineJoin = strokeState.lineJoin;
context.lineJoin = strokeState.lineJoin;
} }
if (contextStrokeState.lineWidth != strokeState.lineWidth) { if (contextStrokeState.lineWidth != strokeState.lineWidth) {
contextStrokeState.lineWidth = context.lineWidth = strokeState.lineWidth; contextStrokeState.lineWidth = strokeState.lineWidth;
context.lineWidth = strokeState.lineWidth;
} }
if (contextStrokeState.miterLimit != strokeState.miterLimit) { if (contextStrokeState.miterLimit != strokeState.miterLimit) {
contextStrokeState.miterLimit = context.miterLimit = contextStrokeState.miterLimit = strokeState.miterLimit;
strokeState.miterLimit; context.miterLimit = strokeState.miterLimit;
} }
if (contextStrokeState.strokeStyle != strokeState.strokeStyle) { if (contextStrokeState.strokeStyle != strokeState.strokeStyle) {
contextStrokeState.strokeStyle = context.strokeStyle = contextStrokeState.strokeStyle = strokeState.strokeStyle;
strokeState.strokeStyle; context.strokeStyle = strokeState.strokeStyle;
} }
} }
} }
@@ -800,14 +804,16 @@ class CanvasImmediateRenderer extends VectorContext {
}; };
} else { } else {
if (contextTextState.font != textState.font) { if (contextTextState.font != textState.font) {
contextTextState.font = context.font = textState.font; contextTextState.font = textState.font;
context.font = textState.font;
} }
if (contextTextState.textAlign != textAlign) { if (contextTextState.textAlign != textAlign) {
contextTextState.textAlign = context.textAlign = /** @type {CanvasTextAlign} */ (textAlign); contextTextState.textAlign = /** @type {CanvasTextAlign} */ (textAlign);
context.textAlign = /** @type {CanvasTextAlign} */ (textAlign);
} }
if (contextTextState.textBaseline != textState.textBaseline) { if (contextTextState.textBaseline != textState.textBaseline) {
contextTextState.textBaseline = context.textBaseline = contextTextState.textBaseline = /** @type {CanvasTextBaseline} */ (textState.textBaseline);
/** @type {CanvasTextBaseline} */ (textState.textBaseline); context.textBaseline = /** @type {CanvasTextBaseline} */ (textState.textBaseline);
} }
} }
} }

View File

@@ -50,7 +50,8 @@ class LabelCache extends LRUCache {
} }
} }
const canvas = this.pop(); const canvas = this.pop();
canvas.width = canvas.height = 0; canvas.width = 0;
canvas.height = 0;
for (const consumerId in this.consumers) { for (const consumerId in this.consumers) {
delete this.consumers[consumerId][key]; delete this.consumers[consumerId][key];
} }

View File

@@ -392,11 +392,13 @@ class CanvasTextBuilder extends CanvasBuilder {
const textFillStyle = textStyle.getFill(); const textFillStyle = textStyle.getFill();
if (!textFillStyle) { if (!textFillStyle) {
fillState = this.textFillState_ = null; fillState = null;
this.textFillState_ = fillState;
} else { } else {
fillState = this.textFillState_; fillState = this.textFillState_;
if (!fillState) { if (!fillState) {
fillState = this.textFillState_ = /** @type {import("../canvas.js").FillState} */ ({}); fillState = /** @type {import("../canvas.js").FillState} */ ({});
this.textFillState_ = fillState;
} }
fillState.fillStyle = asColorLike( fillState.fillStyle = asColorLike(
textFillStyle.getColor() || defaultFillStyle); textFillStyle.getColor() || defaultFillStyle);
@@ -404,11 +406,13 @@ class CanvasTextBuilder extends CanvasBuilder {
const textStrokeStyle = textStyle.getStroke(); const textStrokeStyle = textStyle.getStroke();
if (!textStrokeStyle) { if (!textStrokeStyle) {
strokeState = this.textStrokeState_ = null; strokeState = null;
this.textStrokeState_ = strokeState;
} else { } else {
strokeState = this.textStrokeState_; strokeState = this.textStrokeState_;
if (!strokeState) { if (!strokeState) {
strokeState = this.textStrokeState_ = /** @type {import("../canvas.js").StrokeState} */ ({}); strokeState = /** @type {import("../canvas.js").StrokeState} */ ({});
this.textStrokeState_ = strokeState;
} }
const lineDash = textStrokeStyle.getLineDash(); const lineDash = textStrokeStyle.getLineDash();
const lineDashOffset = textStrokeStyle.getLineDashOffset(); const lineDashOffset = textStrokeStyle.getLineDashOffset();

View File

@@ -90,7 +90,8 @@ export function createHitDetectionImageData(size, transforms, features, styleFun
const zIndex = Number(style.getZIndex()); const zIndex = Number(style.getZIndex());
let byGeometryType = featuresByZIndex[zIndex]; let byGeometryType = featuresByZIndex[zIndex];
if (!byGeometryType) { if (!byGeometryType) {
byGeometryType = featuresByZIndex[zIndex] = {}; byGeometryType = {};
featuresByZIndex[zIndex] = byGeometryType;
byGeometryType[GeometryType.POLYGON] = []; byGeometryType[GeometryType.POLYGON] = [];
byGeometryType[GeometryType.CIRCLE] = []; byGeometryType[GeometryType.CIRCLE] = [];
byGeometryType[GeometryType.LINE_STRING] = []; byGeometryType[GeometryType.LINE_STRING] = [];

View File

@@ -92,7 +92,8 @@ class CanvasImageLayerRenderer extends CanvasLayerRenderer {
const rotation = viewState.rotation; const rotation = viewState.rotation;
if (rotation) { if (rotation) {
const size = Math.round(Math.sqrt(width * width + height * height)); const size = Math.round(Math.sqrt(width * width + height * height));
width = height = size; width = size;
height = size;
} }
// set forward and inverse pixel transforms // set forward and inverse pixel transforms

View File

@@ -175,7 +175,8 @@ class CanvasTileLayerRenderer extends CanvasLayerRenderer {
if (rotation) { if (rotation) {
const size = Math.round(Math.sqrt(width * width + height * height)); const size = Math.round(Math.sqrt(width * width + height * height));
width = height = size; width = size;
height = size;
} }
const dx = tileResolution * width / 2 / tilePixelRatio; const dx = tileResolution * width / 2 / tilePixelRatio;

View File

@@ -169,7 +169,10 @@ export function writePointFeatureToBuffers(instructions, elementIndex, vertexBuf
export function getBlankImageData() { export function getBlankImageData() {
const canvas = document.createElement('canvas'); const canvas = document.createElement('canvas');
const image = canvas.getContext('2d').createImageData(1, 1); const image = canvas.getContext('2d').createImageData(1, 1);
image.data[0] = image.data[1] = image.data[2] = image.data[3] = 255; image.data[0] = 255;
image.data[1] = 255;
image.data[2] = 255;
image.data[3] = 255;
return image; return image;
} }

View File

@@ -70,7 +70,8 @@ export function toSize(size, opt_size) {
if (opt_size === undefined) { if (opt_size === undefined) {
opt_size = [size, size]; opt_size = [size, size];
} else { } else {
opt_size[0] = opt_size[1] = size; opt_size[0] = size;
opt_size[1] = size;
} }
return opt_size; return opt_size;
} }

View File

@@ -180,7 +180,8 @@ class UrlTile extends TileSource {
* @api * @api
*/ */
setUrl(url) { setUrl(url) {
const urls = this.urls = expandUrl(url); const urls = expandUrl(url);
this.urls = urls;
this.setUrls(urls); this.setUrls(urls);
} }

View File

@@ -380,8 +380,9 @@ class VectorTile extends UrlTile {
// A tile grid that matches the tile size of the source tile grid is more // A tile grid that matches the tile size of the source tile grid is more
// likely to have 1:1 relationships between source tiles and rendered tiles. // likely to have 1:1 relationships between source tiles and rendered tiles.
const sourceTileGrid = this.tileGrid; const sourceTileGrid = this.tileGrid;
tileGrid = this.tileGrids_[code] = createForProjection(projection, undefined, tileGrid = createForProjection(projection, undefined,
sourceTileGrid ? sourceTileGrid.getTileSize(sourceTileGrid.getMinZoom()) : undefined); sourceTileGrid ? sourceTileGrid.getTileSize(sourceTileGrid.getMinZoom()) : undefined);
this.tileGrids_[code] = tileGrid;
} }
return tileGrid; return tileGrid;
} }

View File

@@ -114,7 +114,7 @@ export function expandUrl(url) {
} }
return urls; return urls;
} }
match = match = /\{(\d+)-(\d+)\}/.exec(url); match = /\{(\d+)-(\d+)\}/.exec(url);
if (match) { if (match) {
// number range // number range
const stop = parseInt(match[2], 10); const stop = parseInt(match[2], 10);

View File

@@ -379,10 +379,11 @@ class WebGLHelper extends Disposable {
let bufferCache = this.bufferCache_[bufferKey]; let bufferCache = this.bufferCache_[bufferKey];
if (!bufferCache) { if (!bufferCache) {
const webGlBuffer = gl.createBuffer(); const webGlBuffer = gl.createBuffer();
bufferCache = this.bufferCache_[bufferKey] = { bufferCache = {
buffer: buffer, buffer: buffer,
webGlBuffer: webGlBuffer webGlBuffer: webGlBuffer
}; };
this.bufferCache_[bufferKey] = bufferCache;
} }
gl.bindBuffer(buffer.getType(), bufferCache.webGlBuffer); gl.bindBuffer(buffer.getType(), bufferCache.webGlBuffer);
} }

View File

@@ -215,7 +215,8 @@ export function makeObjectPropertyPusher(valueReader, opt_property, opt_this) {
if (property in object) { if (property in object) {
array = object[property]; array = object[property];
} else { } else {
array = object[property] = []; array = [];
object[property] = array;
} }
array.push(value); array.push(value);
} }

View File

@@ -23,7 +23,8 @@ describe('ol.control.Attribution', function() {
beforeEach(function() { beforeEach(function() {
const target = document.createElement('div'); const target = document.createElement('div');
target.style.width = target.style.height = '100px'; target.style.width = '100px';
target.style.height = '100px';
document.body.appendChild(target); document.body.appendChild(target);
map = new Map({ map = new Map({
target: target, target: target,

View File

@@ -197,7 +197,8 @@ describe('ol.Map', function() {
let map; let map;
beforeEach(function() { beforeEach(function() {
const target = document.createElement('div'); const target = document.createElement('div');
target.style.width = target.style.height = '100px'; target.style.width = '100px';
target.style.height = '100px';
document.body.appendChild(target); document.body.appendChild(target);
map = new Map({ map = new Map({
target: target, target: target,
@@ -259,7 +260,8 @@ describe('ol.Map', function() {
let target, map, layer; let target, map, layer;
beforeEach(function() { beforeEach(function() {
target = document.createElement('div'); target = document.createElement('div');
target.style.width = target.style.height = '100px'; target.style.width = '100px';
target.style.height = '100px';
document.body.appendChild(target); document.body.appendChild(target);
layer = new VectorLayer({ layer = new VectorLayer({
source: new VectorSource({ source: new VectorSource({
@@ -360,7 +362,8 @@ describe('ol.Map', function() {
useGeographic(); useGeographic();
target = document.createElement('div'); target = document.createElement('div');
target.style.width = target.style.height = size + 'px'; target.style.width = size + 'px';
target.style.height = size + 'px';
document.body.appendChild(target); document.body.appendChild(target);
map = new Map({ map = new Map({
@@ -413,7 +416,8 @@ describe('ol.Map', function() {
useGeographic(); useGeographic();
target = document.createElement('div'); target = document.createElement('div');
target.style.width = target.style.height = size + 'px'; target.style.width = size + 'px';
target.style.height = size + 'px';
document.body.appendChild(target); document.body.appendChild(target);
map = new Map({ map = new Map({

View File

@@ -81,7 +81,8 @@ describe('ol.renderer.canvas.ImageLayer', function() {
}); });
div = document.createElement('div'); div = document.createElement('div');
div.style.width = div.style.height = '100px'; div.style.width = '100px';
div.style.height = '100px';
document.body.appendChild(div); document.body.appendChild(div);
map = new Map({ map = new Map({
target: div, target: div,
@@ -131,7 +132,8 @@ describe('ol.renderer.canvas.ImageLayer', function() {
}); });
div = document.createElement('div'); div = document.createElement('div');
div.style.width = div.style.height = '100px'; div.style.width = '100px';
div.style.height = '100px';
document.body.appendChild(div); document.body.appendChild(div);
map = new Map({ map = new Map({
target: div, target: div,

View File

@@ -408,7 +408,8 @@ describe('ol.source.ImageWMS', function() {
source.loading = false; source.loading = false;
}); });
const target = document.createElement('div'); const target = document.createElement('div');
target.style.width = target.style.height = '100px'; target.style.width = '100px';
target.style.height = '100px';
document.body.appendChild(target); document.body.appendChild(target);
map = new Map({ map = new Map({
target: target, target: target,

View File

@@ -158,7 +158,8 @@ describe('ol.source.Vector', function() {
url: 'spec/ol/source/vectorsource/single-feature.json' url: 'spec/ol/source/vectorsource/single-feature.json'
}); });
const target = document.createElement('div'); const target = document.createElement('div');
target.style.width = target.style.height = '100px'; target.style.width = '100px';
target.style.height = '100px';
document.body.appendChild(target); document.body.appendChild(target);
map = new Map({ map = new Map({
target: target, target: target,
@@ -592,7 +593,8 @@ describe('ol.source.Vector', function() {
} }
}); });
const div = document.createElement('div'); const div = document.createElement('div');
div.style.width = div.style.height = '100px'; div.style.width = '100px';
div.style.height = '100px';
document.body.appendChild(div); document.body.appendChild(div);
const map = new Map({ const map = new Map({
target: div, target: div,

View File

@@ -198,7 +198,8 @@ describe('ol.source.VectorTile', function() {
}); });
target = document.createElement('div'); target = document.createElement('div');
target.style.width = target.style.height = '100px'; target.style.width = '100px';
target.style.height = '100px';
document.body.appendChild(target); document.body.appendChild(target);
map = new Map({ map = new Map({

View File

@@ -206,7 +206,8 @@ describe('ol.source.XYZ', function() {
} }
}); });
const target = document.createElement('div'); const target = document.createElement('div');
target.style.width = target.style.height = '100px'; target.style.width = '100px';
target.style.height = '100px';
document.body.appendChild(target); document.body.appendChild(target);
map = new Map({ map = new Map({
target: target, target: target,