Error on Safari. White blank page

Published 2 months ago by wigogeo

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)
    • prefix {String} qs parameter (__jp)
    • name {String} qs parameter (prefix + incr)
    • timeout {Number} how long after a timeout error is emitted (60000)
  • @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

jlrdw
jlrdw
2 months ago (252,040 XP)

Plead with users to forget all about Safari and use Chrome.

bashy
bashy
2 months ago (1,002,650 XP)

Is this a polyfill issue? https://polyfill.io

wigogeo

@bashy, no it's not. I already include the polyfill js and i still get the error.

bashy
bashy
2 months ago (1,002,650 XP)

Ok, worth a try :)

Please sign in or create an account to participate in this conversation.