Skip to content

Commit 644cb5f

Browse files
author
David Heinemeier Hansson
committed
ES Module Shims 1.4.1
1 parent d649ec5 commit 644cb5f

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

app/assets/javascripts/es-module-shims.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
/* ES Module Shims 1.4.0 */
1+
/* ES Module Shims 1.4.1 */
22
(function () {
33

4-
const edge = navigator.userAgent.match(/Edge\/\d\d\.\d+$/);
4+
const uaMatch = navigator.userAgent.match(/(Edge|Safari)\/\d+\.\d+/);
5+
const edge = uaMatch && uaMatch[1] === 'Edge';
6+
const safari = uaMatch && uaMatch[1] === 'Safari';
57

68
let baseUrl;
79

@@ -762,8 +764,12 @@
762764
if (isDomContentLoadedScript) domContentLoadedCnt++;
763765
const blocks = script.getAttribute('async') === null && isReadyScript;
764766
const loadPromise = topLevelLoad(script.src || `${baseUrl}?${id++}`, getFetchOpts(script), !script.src && script.innerHTML, !shimMode, blocks && lastStaticLoadPromise).catch(e => {
765-
// This used to be a setTimeout(() => { throw e }) but this breaks Safari stacks
766-
console.error(e);
767+
// Safari only gives error via console.error
768+
if (safari)
769+
console.error(e);
770+
// Firefox only gives error stack via setTimeout
771+
else
772+
setTimeout(() => { throw e});
767773
onerror(e);
768774
});
769775
if (blocks)

app/assets/javascripts/es-module-shims.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)