Plead with users to forget all about Safari and use Chrome.
Error on Safari. White blank page
Hi,
i'm running an SPA with Laravel and Vue.
It's working fine on Chrome and Firefox but not on Safari. I get this error : SyntaxError: Strict mode does not allow function declarations in a lexically nested statement.
The error is in this function :
/**
- JSONP handler
- Options:
-
- param {String} qs parameter (
callback)
- param {String} qs parameter (
-
- prefix {String} qs parameter (
__jp)
- prefix {String} qs parameter (
-
- name {String} qs parameter (
prefix+ incr)
- name {String} qs parameter (
-
- timeout {Number} how long after a timeout error is emitted (
60000)
- timeout {Number} how long after a timeout error is emitted (
- @param {String} url
- @param {Object|Function} optional options / callback */
function jsonp(opts) { var prefix = opts.prefix || '__jp';
// use the callback name that was passed if one was provided. // otherwise generate a unique name by incrementing our counter. var id = opts.name || prefix + count++;
var timeout = opts.timeout || 60000; var cacheFlag = opts.cache || false; var enc = encodeURIComponent; var target = document.getElementsByTagName('script')[0] || document.head; var script; var timer; if (!opts.url) { throw new TypeError('url is null or not defined'); } /* eslint-disable */ return new Promise(function(resolve, reject) { try {
function cleanup() { //********* THE ERROR SEND ME RIGHT INTO THIS LINE *****//
if (script.parentNode) script.parentNode.removeChild(script); window[id] = noop; if (timer) clearTimeout(timer); } if (timeout) { timer = setTimeout(function() { cleanup(); reject(new Error('Request timed out')); }, timeout); }
window[id] = function(data) {
cleanup();
resolve(data);
};
// add params
opts.url = buildURL(opts.url, opts.params, opts.paramsSerializer);
//add callback
opts.url +=
(opts.url.indexOf('?') === -1 ? '?' : '&') +
'callback=' +
enc(id);
// cache
!cacheFlag && (opts.url += '&_=' + new Date().getTime());
// create script
script = document.createElement('script');
script.src = opts.url;
target.parentNode.insertBefore(script, target);
} catch (e) {
reject(e);
}
});
}
module.exports = jsonp;
Does someone has an idea to fix this error ?
Thanks
Please or to participate in this conversation.