question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Uncaught (in promise) TypeError: Illegal invocation

See original GitHub issue

Hi, We updated from 10.16.7 to 11.0.5 and now we get an error with the current stack:

/node_modules/sweetalert2/dist/sweetalert2.all.js:284 Uncaught (in promise) TypeError: Illegal invocation
    at runIfFunction (/node_modules/sweetalert2/dist/sweetalert2.all.js:284)
    at blurActiveElement (/node_modules/sweetalert2/dist/sweetalert2.all.js:3253)
    at initFocus (/node_modules/sweetalert2/dist/sweetalert2.all.js:3224)
    at eval (/node_modules/sweetalert2/dist/sweetalert2.all.js:3171)
    at new Promise (<anonymous>)
    at swalPromise (/node_modules/sweetalert2/dist/sweetalert2.all.js:3139)
    at SweetAlert._main (/node_modules/sweetalert2/dist/sweetalert2.all.js:3124)
    at new SweetAlert (/node_modules/sweetalert2/dist/sweetalert2.all.js:3382)
    at _construct (/node_modules/sweetalert2/dist/sweetalert2.all.js:133)
    at Function.fire (/node_modules/sweetalert2/dist/sweetalert2.all.js:1428)

The error is caused in the line 284:

 var runIfFunction = function runIfFunction(fn, arg) {
    if (typeof fn === 'function') fn(arg);  <-- error is marked here
  };

We use Sweetalert inside a function:

const modalRemove = (options, clbk) => {
  Swal.fire({
    title: options.title || i18n.__('common.remove'),
    text: options.text || i18n.__('text.remove'),
    icon: options.icon || 'warning',
    timer: 70000,
    showClass: {
      popup: '', // disable popup animation
    },
    allowEnterKey: false,
    showCancelButton: true,
    reverseButtons: true,
    customClass: {
      confirmButton: 'waves-effect waves-light btn error',
      cancelButton: 'waves-effect waves-dark btn-flat white font-text',
    },
    confirmButtonText: options.confirm || i18n.__('common.remove'),
    cancelButtonText: i18n.__('common.dismiss'),
  }).then((result) => {
    console.log(result);  <-- The process doesn't arrives here
    if (result.isConfirmed) {
      clbk();
    }
  });
};

Any idea? Thanks

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
limontecommented, May 17, 2021

Thanks! The issue is related to allowEnterKey: false. I’ll fix it soon.

0reactions
ixdicommented, May 17, 2021

Perfect, thank you for the quick response!

Read more comments on GitHub >

github_iconTop Results From Across the Web

"Uncaught TypeError: Illegal invocation" in Chrome
In your code you are assigning a native method to a property of custom object. When you call support.animationFrame(function () {}) , it...
Read more >
"Illegal invocation" errors in JavaScript - Matias Kinnunen
An "illegal invocation" error is thrown when calling a function whose this keyword doesn't refer to the object where it originally did. In...
Read more >
Uncaught TypeError: Illegal invocation - jQuery Forum
Hi, I am getting the above error and can't figure our why? kindly help.. This is my code: var formData = new FormData(); ......
Read more >
Uncaught TypeError: Illegal invocation in Ajax function
I'm trying to send a form to my handler, but I get an error "Uncaught TypeError: Illegal invocation". When I try to send...
Read more >
Uncaught (in promise) TypeError: Illegal invocation
Uncaught (in promise) TypeError: Illegal invocation error using jQuery ajax code. To fix the error, try adding `processData: false` and ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found