GoogleChrome / dialog-polyfill

Polyfill for the HTML dialog element
BSD 3-Clause "New" or "Revised" License
2.45k stars 245 forks source link

On Firefox, shows this on console : "Error: Failed to execute 'close' on dialog..." #221

Open Zardoz89 opened 3 years ago

Zardoz89 commented 3 years ago

On Firefox, on the console shows this error every time that I close a dialog :

 Uncaught Error: Failed to execute 'close' on dialog: The element does not have an 'open' attribute, and therefore cannot be closed.
    close dialog-polyfill.js:460
laozhu commented 3 years ago

The same problem here

zarahzachz commented 2 years ago

I'm encountering this issue - any movement on it yet?

Zardoz89 commented 2 years ago

Well... actually you can remove this polyfill on Firefox v >= 98 . It's what I actually I did.

GrimLink commented 2 years ago

Make sure you are using the polyfill only when needed, before registering the dialog, example;

if (typeof HTMLDialogElement !== "function") {
        dialogPolyfill.registerDialog("your-dialog");
}

This should fix any errors you are having.

Zardoz89 commented 2 years ago

This should fix any errors you are having.

Except if the user it's using a older Firefox release (very strange, but can happen)

willzoltan commented 1 year ago

This also happens in older versions of Safari, eg 12.1.2. We solved this by wrapping the call in a try ... catch block