From d722c97762fbd8675000654a1e262125a97ec6e5 Mon Sep 17 00:00:00 2001 From: Pablo Alonso Garcia Date: Wed, 14 Dec 2016 13:50:53 +0100 Subject: [PATCH] swallow SJAX errors during in-browser translation --- source-map-support.js | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/source-map-support.js b/source-map-support.js index 13cdf0c..9c88378 100644 --- a/source-map-support.js +++ b/source-map-support.js @@ -95,16 +95,20 @@ function retrieveSourceMapURL(source) { var fileData; if (isInBrowser()) { - var xhr = new XMLHttpRequest(); - xhr.open('GET', source, false); - xhr.send(null); - fileData = xhr.readyState === 4 ? xhr.responseText : null; + try { + var xhr = new XMLHttpRequest(); + xhr.open('GET', source, false); + xhr.send(null); + fileData = xhr.readyState === 4 ? xhr.responseText : null; - // Support providing a sourceMappingURL via the SourceMap header - var sourceMapHeader = xhr.getResponseHeader("SourceMap") || - xhr.getResponseHeader("X-SourceMap"); - if (sourceMapHeader) { - return sourceMapHeader; + // Support providing a sourceMappingURL via the SourceMap header + var sourceMapHeader = xhr.getResponseHeader("SourceMap") || + xhr.getResponseHeader("X-SourceMap"); + if (sourceMapHeader) { + return sourceMapHeader; + } + } catch (e) { + return null; } }