Skip to content

Commit bae7565

Browse files
committed
【UT】fix 低版本浏览器不支持array.at
1 parent fc0da76 commit bae7565

2 files changed

Lines changed: 16 additions & 2 deletions

File tree

test/mapboxgl/mapping/WebMapV3Spec.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,14 @@ import mbglmap, { CRS, proj4, revertCRS } from '../../tool/mock_mapboxgl_map';
1414
import '../../resources/WebMapV3.js';
1515
import '../../resources/WebMapV5.js';
1616
var server = 'http://localhost:8190/iportal/';
17-
17+
if (!Array.prototype.at) {
18+
Array.prototype.at = function(n) {
19+
n = Math.trunc(n) || 0;
20+
if (n < 0) n += this.length;
21+
if (n < 0 || n >= this.length) return undefined;
22+
return this[n];
23+
};
24+
}
1825
describe('mapboxgl-webmap3.0', () => {
1926
var originalTimeout, testDiv;
2027
var id = 617580084;

test/maplibregl/mapping/WebMapV3Spec.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,14 @@ import * as mockL7 from '../../tool/mock_l7';
1313
import mbglmap, { CRS, proj4 } from '../../tool/mock_maplibregl_map';
1414
import '../../resources/WebMapV3.js';
1515
import '../../resources/WebMapV5.js';
16-
16+
if (!Array.prototype.at) {
17+
Array.prototype.at = function(n) {
18+
n = Math.trunc(n) || 0;
19+
if (n < 0) n += this.length;
20+
if (n < 0 || n >= this.length) return undefined;
21+
return this[n];
22+
};
23+
}
1724
describe('maplibregl-webmap3.0', () => {
1825
var originalTimeout, testDiv;
1926
var server = 'http://localhost:8190/iportal/';

0 commit comments

Comments
 (0)