Sweetalert: swal.close() should check swal.getState()

Created on 29 Sep 2017  ·  3Comments  ·  Source: t4t5/sweetalert

In some modules, I call swal.close() in case there are any left over, which worked in v1, but now:

Uncaught TypeError: Cannot read property 'value' of undefined
at Function.e.onAction [as close] (lib.min.js:606)
at :1:6

This error goes away as soon as a sweet alert was once on screen.

To reproduce, open https://sweetalert.js.org/ and devtools and type swal.close();

Most helpful comment

Not sure why his was closed, i just spent over an hour trying to find out why parsley wasn't preventing form submission, when i should have checked the console for exceptions, ill blame a lack of sleep last night for the fact it took me so long to find it.

I've put a check around my call but i think .close() should be safe to call regardless of if it had been shown previously.

All 3 comments

Not sure why his was closed, i just spent over an hour trying to find out why parsley wasn't preventing form submission, when i should have checked the console for exceptions, ill blame a lack of sleep last night for the fact it took me so long to find it.

I've put a check around my call but i think .close() should be safe to call regardless of if it had been shown previously.

Yeah, I'm not sure why it was closed either.

Found the same problem.
I haven't studied the entire project yet but I discovered where the bug lives
I'll try opening a PR in the future

Was this page helpful?
0 / 5 - 0 ratings

Related issues

fracz picture fracz  ·  4Comments

Lusitaniae picture Lusitaniae  ·  4Comments

voodoo6 picture voodoo6  ·  4Comments

krishnamraju picture krishnamraju  ·  3Comments

waldyrious picture waldyrious  ·  5Comments