wigogeo
210
4
Vue

Error on Safari. White blank page

Posted 11 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

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

Reply to

Use Markdown with GitHub-flavored code blocks.