Merge pull request #12891 from mike-000/compatibility

Restore browser compatibility where possible
This commit is contained in:
Andreas Hocevar
2021-10-18 19:31:40 +02:00
committed by GitHub
6 changed files with 14 additions and 32 deletions

View File

@@ -97,9 +97,10 @@ For older browsers and platforms (Internet Explorer, Android 4.x, iOS v12 and ol
* [`fetch`](https://caniuse.com/fetch): Available from [polyfill.io](https://polyfill.io/). * [`fetch`](https://caniuse.com/fetch): Available from [polyfill.io](https://polyfill.io/).
* [`requestAnimationFrame`](https://caniuse.com/requestanimationframe): Available from [polyfill.io](https://polyfill.io/). * [`requestAnimationFrame`](https://caniuse.com/requestanimationframe): Available from [polyfill.io](https://polyfill.io/).
* [`element.prototype.classList` (`add`/`remove`)](https://caniuse.com/classlist): Available from [polyfill.io](https://polyfill.io/). * [`element.prototype.classList` (`add`/`remove`)](https://caniuse.com/classlist): Available from [polyfill.io](https://polyfill.io/).
* [`URL` API](https://caniuse.com/url): Available from [polyfill.io](https://polyfill.io/). * [`URL` API](https://caniuse.com/url): Available from [polyfill.io](https://polyfill.io/) or [core-js](https://cdnjs.com/libraries/core-js/).
* [`TextDecoder`](https://caniuse.com/textencoder): Available from [polyfill.io](https://polyfill.io/). * [`TextDecoder`](https://caniuse.com/textencoder): Available from [polyfill.io](https://polyfill.io/).
* [`Number.isInteger`](https://caniuse.com/isInteger): Available from [polyfill.io](https://polyfill.io/). * [`Number.isInteger`](https://caniuse.com/isInteger): Available from [polyfill.io](https://polyfill.io/) or [core-js](https://cdnjs.com/libraries/core-js/).
* [`Reflect`](https://caniuse.com/mdn-javascript_builtins_reflect): Available from [core-js](https://cdnjs.com/libraries/core-js/).
* [Pointer events](https://caniuse.com/pointer): Use [elm-pep](https://npmjs.com/package/elm-pep) (lightweight) or [pepjs](https://npmjs.com/package/pepjs) (for really, really old browsers). * [Pointer events](https://caniuse.com/pointer): Use [elm-pep](https://npmjs.com/package/elm-pep) (lightweight) or [pepjs](https://npmjs.com/package/pepjs) (for really, really old browsers).
[`ol/source/GeoTIFF`](https://openlayers.org/en/latest/apidoc/module-ol_source_GeoTIFF-GeoTIFFSource.html) requires a browser that supports [ECMAScript 6](https://262.ecma-international.org/6.0/). Additionally a polyfill for [`Promise.allSettled`](https://caniuse.com/mdn-javascript_builtins_promise_allsettled) may be needed. [`ol/source/GeoTIFF`](https://openlayers.org/en/latest/apidoc/module-ol_source_GeoTIFF-GeoTIFFSource.html) requires a browser that supports [ECMAScript 6](https://262.ecma-international.org/6.0/). Additionally a polyfill for [`Promise.allSettled`](https://caniuse.com/mdn-javascript_builtins_promise_allsettled) may be needed.

View File

@@ -1,21 +0,0 @@
if (typeof Promise !== 'undefined' && !Promise.allSettled && Array.from) {
Promise.allSettled =
function (promises) {
return Promise.all(
Array.from(
promises,
function (p) {
return p.then (
function (value) {
return {status: 'fulfilled', value: value};
}
).catch(
function (reason) {
return {status: 'rejected', reason: reason};
}
);
}
)
)
};
}

View File

@@ -68,8 +68,8 @@
<link rel="stylesheet" href="./css/ol.css" type="text/css"> <link rel="stylesheet" href="./css/ol.css" type="text/css">
<link rel="stylesheet" href="./resources/layout.css" type="text/css"> <link rel="stylesheet" href="./resources/layout.css" type="text/css">
<script src="https://unpkg.com/elm-pep"></script> <script src="https://unpkg.com/elm-pep"></script>
<script src="https://cdn.polyfill.io/v3/polyfill.min.js?features=fetch,requestAnimationFrame,Element.prototype.classList,URL,TextDecoder,Number.isInteger"></script> <script src="https://cdn.polyfill.io/v3/polyfill.min.js?features=fetch,requestAnimationFrame,Element.prototype.classList,TextDecoder"></script>
<script src="./resources/Promise.allSettled.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/core-js/3.18.3/minified.js"></script>
{{{ extraHead.local }}} {{{ extraHead.local }}}
{{{ css.tag }}} {{{ css.tag }}}
<title>{{ title }}</title> <title>{{ title }}</title>
@@ -194,8 +194,9 @@
&lt;title&gt;{{ title }}&lt;/title&gt; &lt;title&gt;{{ title }}&lt;/title&gt;
&lt;!-- Pointer events polyfill for old browsers, see https://caniuse.com/#feat=pointer --&gt; &lt;!-- Pointer events polyfill for old browsers, see https://caniuse.com/#feat=pointer --&gt;
&lt;script src="https://unpkg.com/elm-pep"&gt;&lt;/script&gt; &lt;script src="https://unpkg.com/elm-pep"&gt;&lt;/script&gt;
&lt;!-- The line below is only needed for old environments like Internet Explorer and Android 4.x --&gt; &lt;!-- The lines below are only needed for old environments like Internet Explorer and Android 4.x --&gt;
&lt;script src="https://cdn.polyfill.io/v3/polyfill.min.js?features=fetch,requestAnimationFrame,Element.prototype.classList,URL,TextDecoder,Number.isInteger"&gt;&lt;/script&gt;{{#if extraHead.remote}} &lt;script src="https://cdn.polyfill.io/v3/polyfill.min.js?features=fetch,requestAnimationFrame,Element.prototype.classList,TextDecoder"&gt;&lt;/script&gt;
&lt;script src="https://cdnjs.cloudflare.com/ajax/libs/core-js/3.18.3/minified.js"&gt;&lt;/script&gt;{{#if extraHead.remote}}
{{ indent extraHead.remote spaces=4 }}{{/if}} {{ indent extraHead.remote spaces=4 }}{{/if}}
&lt;style&gt; &lt;style&gt;
.map { .map {

View File

@@ -26,7 +26,7 @@ export default {
module: { module: {
rules: [ rules: [
{ {
test: /^((?!es2015-)[\s\S])*\.js$/, test: /^((?!es2015-)[\s\S])*\.m?js$/,
use: { use: {
loader: 'babel-loader', loader: 'babel-loader',
options: { options: {

View File

@@ -7,8 +7,9 @@
<link href="./legacy/ol.css" rel='stylesheet' type='text/css'> <link href="./legacy/ol.css" rel='stylesheet' type='text/css'>
<!-- Pointer events polyfill for old browsers, see https://caniuse.com/#feat=pointer --> <!-- Pointer events polyfill for old browsers, see https://caniuse.com/#feat=pointer -->
<script src="https://unpkg.com/elm-pep"></script> <script src="https://unpkg.com/elm-pep"></script>
<!-- The line below is only needed for old environments like Internet Explorer and Android 4.x --> <!-- The lines below are only needed for old environments like Internet Explorer and Android 4.x -->
<script src="https://cdn.polyfill.io/v3/polyfill.min.js?features=fetch,requestAnimationFrame,Element.prototype.classList,URL,TextDecoder,Number.isInteger"></script> <script src="https://cdn.polyfill.io/v3/polyfill.min.js?features=fetch,requestAnimationFrame,Element.prototype.classList,TextDecoder"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/core-js/3.18.3/minified.js"></script>
</head> </head>
<body> <body>
<ul> <ul>
@@ -32,4 +33,4 @@
}) })
</script> </script>
</body> </body>
</html> </html>

View File

@@ -380,7 +380,7 @@ class MapboxVectorLayer extends VectorTileLayer {
const source = this.getSource(); const source = this.getSource();
if ( if (
styleSource.url.startsWith('mapbox://') || styleSource.url.indexOf('mapbox://') === 0 ||
styleSource.url.indexOf('{z}') !== -1 styleSource.url.indexOf('{z}') !== -1
) { ) {
// Tile source url, handle it directly // Tile source url, handle it directly