GoogleChrome / dialog-polyfill

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

How to determine if one should load the polyfill #237

Open richard-muvirimi opened 1 year ago

richard-muvirimi commented 1 year ago

Kindly expose a function to determine if the modal element is already present so that the CSS styles can be loaded dynamically.

I know one can check the forceRegister function but having a standard API helps reduce a lot of confusion

replete commented 1 month ago

My solution:

let dialog = document.createElement('dialog')
let polyfillNeeded = (!dialog.showModal || !dialog.close)