RegisterModal with CLASS or ID ?
sadeghbarati opened this issue · 2 comments
var dialog = document.querySelector('.class' OR '#id' OR 'ArrayList of Elements');
dialogPolyfill.registerDialog(dialog)
dialog.showModal();
if (element.localName !== 'dialog') {
throw new Error('Failed to register dialog: The element is not a dialog.');
}
register modal with arrayList not register and throw this error Failed to register dialog: The element is not a dialog.
I ran into this check failing because I was using document.createElement("DIALOG")
instead of document.createElement("dialog")
. At least in Edge, the first call with capital letters results in a HTMLUnknownElement
without a localName
of dialog
. document.querySelector()
should be fine using class or id as long as that class/id evaluates first to a <dialog>
element that you created in the HTML or via document.createElement("dialog")
.
I'm not sure what you mean by ArrayList of Elements
, that wouldn't be valid for document.querySelector()
. See https://developer.mozilla.org/en-US/docs/Learn/CSS/Building_blocks/Selectors