Skip to content

Commit 23a1566

Browse files
committed
优化判断是否支持es6的方法
1 parent 81b6127 commit 23a1566

File tree

4 files changed

+31
-17
lines changed

4 files changed

+31
-17
lines changed

dist/classic/include-classic.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
(function () {
22
var r = new RegExp("(^|(.*?\\/))(include-classic\.js)(\\?|$)"),
3-
s = document.getElementsByTagName('script'), targetScript;
3+
s = document.getElementsByTagName('script'),
4+
targetScript;
45
for (var i = 0; i < s.length; i++) {
56
var src = s[i].getAttribute('src');
67
if (src) {
@@ -35,10 +36,13 @@
3536
var code = "'use strict'; class Foo {}; class Bar extends Foo {};";
3637
try {
3738
(new Function(code))();
38-
return true;
3939
} catch (err) {
4040
return false;
4141
}
42+
if (!Array.from) {
43+
return false;
44+
}
45+
return true;
4246
}
4347

4448
//加载类库资源文件
@@ -146,4 +150,4 @@
146150
load();
147151
window.isLocal = false;
148152
window.server = document.location.toString().match(/file:\/\//) ? "http://localhost:8090" : document.location.protocol + "//" + document.location.host;
149-
})();
153+
})();

dist/leaflet/include-leaflet.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,13 @@
3535
var code = "'use strict'; class Foo {}; class Bar extends Foo {};";
3636
try {
3737
(new Function(code))();
38-
return true;
3938
} catch (err) {
4039
return false;
4140
}
41+
if (!Array.from) {
42+
return false;
43+
}
44+
return true;
4245
}
4346

4447
//加载类库资源文件

dist/mapboxgl/include-mapboxgl.js

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
(function () {
22
var r = new RegExp("(^|(.*?\\/))(include-mapboxgl\.js)(\\?|$)"),
3-
s = document.getElementsByTagName('script'), targetScript;
3+
s = document.getElementsByTagName('script'),
4+
targetScript;
45
for (var i = 0; i < s.length; i++) {
56
var src = s[i].getAttribute('src');
67
if (src) {
@@ -35,10 +36,13 @@
3536
var code = "'use strict'; class Foo {}; class Bar extends Foo {};";
3637
try {
3738
(new Function(code))();
38-
return true;
3939
} catch (err) {
4040
return false;
4141
}
42+
if (!Array.from) {
43+
return false;
44+
}
45+
return true;
4246
}
4347

4448
//加载类库资源文件
@@ -67,7 +71,7 @@
6771
if (inArray(includes, 'three')) {
6872
inputScript("https://cdn.bootcss.com/three.js/92/three.min.js");
6973
}
70-
if(inArray(includes,'deck')){
74+
if (inArray(includes, 'deck')) {
7175
inputScript("http://iclient.supermap.io/web/libs/deck.gl/5.1.3/deck.gl.js");
7276
}
7377
if (!inArray(excludes, 'iclient9-mapboxgl')) {
@@ -79,21 +83,21 @@
7983
}
8084
}
8185
}
82-
if(inArray(includes,'LoaderSupport')){
86+
if (inArray(includes, 'LoaderSupport')) {
8387
inputScript("http://iclient.supermap.io/libs/three/plugins/loaders/LoaderCommons.js");
8488
inputScript("http://iclient.supermap.io/libs/three/plugins/loaders/LoaderBuilder.js");
8589
inputScript("http://iclient.supermap.io/libs/three/plugins/loaders/LoaderWorkerSupport.js");
8690
}
87-
if(inArray(includes,'OBJLoader')){
91+
if (inArray(includes, 'OBJLoader')) {
8892
inputScript("http://iclient.supermap.io/libs/three/plugins/loaders/OBJLoader.js");
8993
}
90-
if(inArray(includes,'OBJLoader2')){
94+
if (inArray(includes, 'OBJLoader2')) {
9195
inputScript("http://iclient.supermap.io/libs/three/plugins/loaders/OBJLoader2.js");
9296
}
93-
if(inArray(includes,'MTLLoader')){
97+
if (inArray(includes, 'MTLLoader')) {
9498
inputScript("http://iclient.supermap.io/libs/three/plugins/loaders/MTLLoader.js");
9599
}
96-
if(inArray(includes,'GLTFLoader')){
100+
if (inArray(includes, 'GLTFLoader')) {
97101
inputScript("http://iclient.supermap.io/libs/three/plugins/loaders/GLTFLoader.js");
98102
}
99103
if (inArray(includes, 'proj4')) {
@@ -110,4 +114,4 @@
110114
load();
111115
window.isLocal = false;
112116
window.server = document.location.toString().match(/file:\/\//) ? "http://localhost:8090" : document.location.protocol + "//" + document.location.host;
113-
})();
117+
})();

dist/openlayers/include-openlayers.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,13 @@
3636
var code = "'use strict'; class Foo {}; class Bar extends Foo {};";
3737
try {
3838
(new Function(code))();
39-
return true;
4039
} catch (err) {
4140
return false;
4241
}
42+
if (!Array.from) {
43+
return false;
44+
}
45+
return true;
4346
}
4447

4548
//加载类库资源文件
@@ -59,7 +62,7 @@
5962
if (inArray(includes, 'ol-mapbox-style')) {
6063
inputScript("http://iclient.supermap.io/web/libs/openlayers/plugins/ol-mapbox-style/2.11.2/olms.js");
6164
}
62-
65+
6366
if (inArray(includes, 'deck')) {
6467
inputScript("http://iclient.supermap.io/web/libs/deck.gl/5.1.3/deck.gl.js");
6568
}
@@ -80,7 +83,7 @@
8083
}
8184
if (inArray(includes, 'ol3-echarts')) {
8285
inputScript("http://iclient.supermap.io/libs/openlayers/ol3-echarts/1.3.4/ol3Echarts.min.js");
83-
}
86+
}
8487
if (inArray(includes, 'osmbuildings')) {
8588
inputScript("http://iclient.supermap.io/libs/osmbuildings/OSMBuildings-OL3.js");
8689
}
@@ -94,7 +97,7 @@
9497
inputCSS("http://iclient.supermap.io/libs/openlayers/plugins/ol-layerswitcher/2.0.0/ol-layerswitcher.css");
9598
inputScript("http://iclient.supermap.io/libs/openlayers/plugins/ol-layerswitcher/2.0.0/ol-layerswitcher.js");
9699
}
97-
100+
98101
}
99102

100103
load();

0 commit comments

Comments
 (0)