{"_id":"dialog-closedby-polyfill","_rev":"8-9a012536f7b2a96f6559d4669889793a","name":"dialog-closedby-polyfill","dist-tags":{"latest":"1.4.1"},"versions":{"1.0.0":{"name":"dialog-closedby-polyfill","version":"1.0.0","keywords":["dialog","closedby","polyfill","html5","web-components"],"author":{"url":"https://www.tak-dcxi.com","name":"Takahiro Arai"},"license":"MIT","_id":"dialog-closedby-polyfill@1.0.0","maintainers":[{"name":"takahiro_arai","email":"tak.a.dcxi@gmail.com"}],"homepage":"https://github.com/tak-dcxi/dialog-closedby-polyfill#readme","bugs":{"url":"https://github.com/tak-dcxi/dialog-closedby-polyfill/issues"},"dist":{"shasum":"72eb17891165960c74fa6479d15cee7532e95e1c","tarball":"https://registry.npmjs.org/dialog-closedby-polyfill/-/dialog-closedby-polyfill-1.0.0.tgz","fileCount":4,"integrity":"sha512-dM6aENrOkdp8jlzo0y14dV1g3HnRPpgGiWYmWCbzLBZB2Nguk4mzCK+4JR8ic1L5zkDeRqAe1d8EO4eOPy7tfw==","signatures":[{"sig":"MEUCIQDXchHM2fDbNiQ4ZmUXRfux30ERihNCyBVWFJ3dmdq85wIgE+GsiyeWdQaV9z4w49O9ttkMBMABTrLjM65mcFzP1Gk=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":15433},"main":"index.js","types":"index.d.ts","exports":{".":{"types":"./index.d.ts","import":"./index.js","require":"./index.js"}},"gitHead":"2a7055afa7d4c8445eb795086cedf2e42dea6790","scripts":{"test":"echo \"Open test/index.html in a browser to test\"","build":"esbuild src/index.ts --bundle --format=esm --outfile=index.js","prepublishOnly":"npm run build"},"_npmUser":{"name":"takahiro_arai","email":"tak.a.dcxi@gmail.com"},"repository":{"url":"git+https://github.com/tak-dcxi/dialog-closedby-polyfill.git","type":"git"},"_npmVersion":"10.9.2","description":"Polyfill for the HTMLDialogElement closedBy attribute","directories":{},"_nodeVersion":"23.9.0","_hasShrinkwrap":false,"devDependencies":{"esbuild":"^0.25.4","typescript":"^5.0.0","@types/node":"^20.0.0"},"_npmOperationalInternal":{"tmp":"tmp/dialog-closedby-polyfill_1.0.0_1748037348917_0.47713400969421005","host":"s3://npm-registry-packages-npm-production"}},"1.0.1":{"name":"dialog-closedby-polyfill","version":"1.0.1","keywords":["dialog","closedby","polyfill","html5","web-components"],"author":{"url":"https://www.tak-dcxi.com","name":"Takahiro Arai"},"license":"MIT","_id":"dialog-closedby-polyfill@1.0.1","maintainers":[{"name":"takahiro_arai","email":"tak.a.dcxi@gmail.com"}],"homepage":"https://github.com/tak-dcxi/dialog-closedby-polyfill#readme","bugs":{"url":"https://github.com/tak-dcxi/dialog-closedby-polyfill/issues"},"dist":{"shasum":"741bfceca4e218b244b9ec651f45171a6b2883e5","tarball":"https://registry.npmjs.org/dialog-closedby-polyfill/-/dialog-closedby-polyfill-1.0.1.tgz","fileCount":5,"integrity":"sha512-UnfIXsn8d5SB049VwAziKays5Z755KHQi5DUpI1AilQJyBAQ8GfHC19W7nz7zmkut0larMVwi8tA4+C8ITSZlw==","signatures":[{"sig":"MEYCIQCj6MZPXaMVh4bWMHRnw7arwKewXvk0h+DuUNvHYklIoAIhANnSVa9U16sAgn3hh8okGgx+Nrg1DabkllwhtsOGg1+H","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":16456},"main":"index.js","types":"index.d.ts","exports":{".":{"types":"./index.d.ts","import":"./index.js","require":"./index.js"}},"gitHead":"60316f68bf87216af447bb8bf0353c9373c8c280","scripts":{"build":"esbuild src/index.ts --bundle --format=esm --outfile=index.js","prepublishOnly":"npm run build"},"_npmUser":{"name":"takahiro_arai","email":"tak.a.dcxi@gmail.com"},"repository":{"url":"git+https://github.com/tak-dcxi/dialog-closedby-polyfill.git","type":"git"},"_npmVersion":"10.9.2","description":"Polyfill for the HTMLDialogElement closedBy attribute","directories":{},"_nodeVersion":"23.9.0","_hasShrinkwrap":false,"devDependencies":{"esbuild":"^0.25.4","typescript":"^5.0.0","@types/node":"^20.0.0"},"_npmOperationalInternal":{"tmp":"tmp/dialog-closedby-polyfill_1.0.1_1748042879261_0.04174548890684626","host":"s3://npm-registry-packages-npm-production"}},"1.1.0":{"name":"dialog-closedby-polyfill","version":"1.1.0","keywords":["dialog","closedby","polyfill","html5","web-components"],"author":{"url":"https://www.tak-dcxi.com","name":"Takahiro Arai"},"license":"MIT","_id":"dialog-closedby-polyfill@1.1.0","maintainers":[{"name":"takahiro_arai","email":"tak.a.dcxi@gmail.com"}],"homepage":"https://github.com/tak-dcxi/dialog-closedby-polyfill#readme","bugs":{"url":"https://github.com/tak-dcxi/dialog-closedby-polyfill/issues"},"dist":{"shasum":"38d3e11a5f0abd298a59e9d129cf848d36ed1d47","tarball":"https://registry.npmjs.org/dialog-closedby-polyfill/-/dialog-closedby-polyfill-1.1.0.tgz","fileCount":5,"integrity":"sha512-A/7THz1NUfErs+Dh+4mza2uRaNe4rD5PaXVSetEOTXF9kSwFanmwV0RjHRrojXjxPk54pwxX19njKMq246IIGA==","signatures":[{"sig":"MEUCIAoyFiBaa4iMOGR4rRvArvRb+EwPpvcFXnXwEIHctql9AiEA5dfh8nQCIvUERhFIDtTiLkAwLApdzXveHZzs92A2NLM=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":17574},"main":"index.js","types":"index.d.ts","exports":{".":{"types":"./index.d.ts","import":"./index.js","require":"./index.js"}},"gitHead":"049b155ff72bf72c286ae3e5b2d4bfd8a5312f3f","scripts":{"build":"esbuild src/index.ts --bundle --format=esm --outfile=index.js","prepublishOnly":"npm run build"},"_npmUser":{"name":"takahiro_arai","email":"tak.a.dcxi@gmail.com"},"repository":{"url":"git+https://github.com/tak-dcxi/dialog-closedby-polyfill.git","type":"git"},"_npmVersion":"10.9.2","description":"Polyfill for the HTMLDialogElement closedBy attribute","directories":{},"_nodeVersion":"23.9.0","_hasShrinkwrap":false,"devDependencies":{"esbuild":"^0.25.4","typescript":"^5.0.0","@types/node":"^20.0.0"},"_npmOperationalInternal":{"tmp":"tmp/dialog-closedby-polyfill_1.1.0_1748138637275_0.8560733719631599","host":"s3://npm-registry-packages-npm-production"}},"1.1.1":{"name":"dialog-closedby-polyfill","version":"1.1.1","keywords":["dialog","closedby","polyfill","html5","web-components"],"author":{"url":"https://www.tak-dcxi.com","name":"Takahiro Arai"},"license":"MIT","_id":"dialog-closedby-polyfill@1.1.1","maintainers":[{"name":"takahiro_arai","email":"tak.a.dcxi@gmail.com"}],"homepage":"https://github.com/tak-dcxi/dialog-closedby-polyfill#readme","bugs":{"url":"https://github.com/tak-dcxi/dialog-closedby-polyfill/issues"},"dist":{"shasum":"9ff29106489eb6098e462cc90b034883fabffb28","tarball":"https://registry.npmjs.org/dialog-closedby-polyfill/-/dialog-closedby-polyfill-1.1.1.tgz","fileCount":5,"integrity":"sha512-oXPL9U5EhT9f6yia9ziZzlOLQDh6hU3CIJD29To69CmWMw1nwi7b6TrY1WBeE8Bd1KdwcLJx626AObFpzLtAlA==","signatures":[{"sig":"MEUCIQDxIwTCROKYTIQxdACHf2OyBEHZfyjoqv2r3jpyhvdyiAIgUj8nrp0cX3xT64Wn59KIlJzYJBvO1kZgRA6pgTFTwBw=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":18236},"main":"index.js","types":"index.d.ts","exports":{".":{"types":"./index.d.ts","import":"./index.js","require":"./index.js"}},"gitHead":"0798ad92bd49a537c30f634ffea06bc279fdcd1f","scripts":{"build":"esbuild src/index.ts --bundle --format=esm --outfile=index.js","prepublishOnly":"npm run build"},"_npmUser":{"name":"takahiro_arai","email":"tak.a.dcxi@gmail.com"},"repository":{"url":"git+https://github.com/tak-dcxi/dialog-closedby-polyfill.git","type":"git"},"_npmVersion":"10.9.2","description":"Polyfill for the HTMLDialogElement closedBy attribute","directories":{},"_nodeVersion":"23.9.0","_hasShrinkwrap":false,"devDependencies":{"esbuild":"^0.25.4","typescript":"^5.0.0","@types/node":"^20.0.0"},"_npmOperationalInternal":{"tmp":"tmp/dialog-closedby-polyfill_1.1.1_1770711445350_0.3414673389192988","host":"s3://npm-registry-packages-npm-production"}},"1.2.0":{"name":"dialog-closedby-polyfill","version":"1.2.0","keywords":["dialog","closedby","polyfill","html5","web-components"],"author":{"url":"https://www.tak-dcxi.com","name":"Takahiro Arai"},"license":"MIT","_id":"dialog-closedby-polyfill@1.2.0","maintainers":[{"name":"takahiro_arai","email":"tak.a.dcxi@gmail.com"}],"homepage":"https://github.com/tak-dcxi/dialog-closedby-polyfill#readme","bugs":{"url":"https://github.com/tak-dcxi/dialog-closedby-polyfill/issues"},"dist":{"shasum":"4df6e4c64ec497283a9d6d7ea97f691fcd40ff43","tarball":"https://registry.npmjs.org/dialog-closedby-polyfill/-/dialog-closedby-polyfill-1.2.0.tgz","fileCount":5,"integrity":"sha512-QYqiWCpHQWGv82NgD8e7lJBQrorpRbE7D6i0bIVsurSvwdC0I9S1pNwZZmnwS5DiWseJc8CKPtb6B6DBp4+Waw==","signatures":[{"sig":"MEUCIQDvs9sq2QE0tZgsOJOusI3rE3jA9BOv9aC2kXxDVhkAXwIgEnzgxWcX9eMNXYMui6ZIyhUQdtguFcDRGNEWVsfjsjc=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":18236},"main":"index.js","types":"index.d.ts","exports":{".":{"types":"./index.d.ts","import":"./index.js","require":"./index.js"}},"gitHead":"6412b054e2e88413e57d553a788a04fb435ef1e4","scripts":{"build":"esbuild src/index.ts --bundle --format=esm --outfile=index.js","prepublishOnly":"npm run build"},"_npmUser":{"name":"takahiro_arai","email":"tak.a.dcxi@gmail.com"},"repository":{"url":"git+https://github.com/tak-dcxi/dialog-closedby-polyfill.git","type":"git"},"_npmVersion":"10.9.2","description":"Polyfill for the HTMLDialogElement closedBy attribute","directories":{},"_nodeVersion":"23.9.0","_hasShrinkwrap":false,"devDependencies":{"esbuild":"^0.25.4","typescript":"^5.0.0","@types/node":"^20.0.0"},"_npmOperationalInternal":{"tmp":"tmp/dialog-closedby-polyfill_1.2.0_1770711571741_0.1189772097261328","host":"s3://npm-registry-packages-npm-production"}},"1.3.0":{"name":"dialog-closedby-polyfill","version":"1.3.0","keywords":["dialog","closedby","polyfill","html5","web-components"],"author":{"url":"https://www.tak-dcxi.com","name":"Takahiro Arai"},"license":"MIT","_id":"dialog-closedby-polyfill@1.3.0","maintainers":[{"name":"takahiro_arai","email":"tak.a.dcxi@gmail.com"}],"homepage":"https://github.com/tak-dcxi/dialog-closedby-polyfill#readme","bugs":{"url":"https://github.com/tak-dcxi/dialog-closedby-polyfill/issues"},"dist":{"shasum":"9c4cbc7dabac302942a69975788ff08e6084eb69","tarball":"https://registry.npmjs.org/dialog-closedby-polyfill/-/dialog-closedby-polyfill-1.3.0.tgz","fileCount":5,"integrity":"sha512-II3pxe/zr5OLhbqrkjQgXDFp61ICPlGZspNIgERwUUCLLHgQzPjv3VTStGD4W+ujwR5zMCZAdcWgu5nTmOIUYQ==","signatures":[{"sig":"MEUCIFvJEn2Fvd4CfirEhH6J4hrqBkpwQPuhC/PW4ztYAIQkAiEA/iqWuz2YZs0eoxBj17F9ztqexUZ79VCsbWmybNO0Krw=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":21659},"main":"index.js","types":"index.d.ts","exports":{".":{"types":"./index.d.ts","import":"./index.js","require":"./index.js"}},"gitHead":"d341e63770ab654307f5995b30a869497f3d96aa","scripts":{"build":"esbuild src/index.ts --bundle --format=esm --outfile=index.js","prepublishOnly":"npm run build"},"_npmUser":{"name":"takahiro_arai","email":"tak.a.dcxi@gmail.com"},"repository":{"url":"git+https://github.com/tak-dcxi/dialog-closedby-polyfill.git","type":"git"},"_npmVersion":"10.9.2","description":"Polyfill for the HTMLDialogElement closedBy attribute","directories":{},"_nodeVersion":"23.9.0","_hasShrinkwrap":false,"devDependencies":{"esbuild":"^0.25.4","typescript":"^5.0.0","@types/node":"^20.0.0"},"_npmOperationalInternal":{"tmp":"tmp/dialog-closedby-polyfill_1.3.0_1770716359692_0.2962941792744862","host":"s3://npm-registry-packages-npm-production"}},"1.4.0":{"name":"dialog-closedby-polyfill","version":"1.4.0","keywords":["dialog","closedby","polyfill","html5","web-components"],"author":{"url":"https://www.tak-dcxi.com","name":"Takahiro Arai"},"license":"MIT","_id":"dialog-closedby-polyfill@1.4.0","maintainers":[{"name":"takahiro_arai","email":"tak.a.dcxi@gmail.com"}],"homepage":"https://github.com/tak-dcxi/dialog-closedby-polyfill#readme","bugs":{"url":"https://github.com/tak-dcxi/dialog-closedby-polyfill/issues"},"dist":{"shasum":"51ac1c328b94cc794c2c1aab1a6a4f111761d4f9","tarball":"https://registry.npmjs.org/dialog-closedby-polyfill/-/dialog-closedby-polyfill-1.4.0.tgz","fileCount":11,"integrity":"sha512-ndrASHRWiPhAN1Vu4kzSHFoeqvk04julTtfR4IMP+I7xJvFH9OodurjPAQgK90IvrGZSSIgYLZ3QwPt5oXSH4A==","signatures":[{"sig":"MEYCIQDlsqFnTg+9m0ZFaltO7UrvTRiSqy+pRovEUWPVaXtytwIhALlPX94F+W17MehrbxT1DfnSMoS/fsVdn54fsYg/ns0E","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"sig":"MEQCIF5g1lu3UUT3gqoSe3AL2MpdakQgzfxTub5ELidUglnyAiBvIVKeyBUbnDj47lhj7+QlyLlQsAlKCiC0zLZ2UGKWhA==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":45435},"main":"./index.js","type":"module","types":"./index.d.ts","exports":{".":{"import":{"types":"./index.d.ts","default":"./index.js"},"require":{"types":"./index.d.cts","default":"./index.cjs"}},"./fn":{"import":{"types":"./fn.d.ts","default":"./fn.js"},"require":{"types":"./fn.d.cts","default":"./fn.cjs"}},"./package.json":"./package.json"},"gitHead":"5396d24876b4cbfefdf13f4a24412d3395be7efd","scripts":{"build":"node scripts/build.mjs","typecheck":"tsc --noEmit","prepublishOnly":"npm run typecheck && npm run build"},"_npmUser":{"name":"takahiro_arai","email":"tak.a.dcxi@gmail.com"},"repository":{"url":"git+https://github.com/tak-dcxi/dialog-closedby-polyfill.git","type":"git"},"_npmVersion":"11.17.0","description":"Polyfill for the HTMLDialogElement closedBy attribute","directories":{},"sideEffects":["./index.js","./index.cjs"],"_nodeVersion":"24.19.0","_hasShrinkwrap":false,"devDependencies":{"esbuild":"^0.25.4","typescript":"^5.0.0","@types/node":"^20.0.0"},"_npmOperationalInternal":{"tmp":"tmp/dialog-closedby-polyfill_1.4.0_1794044338614_0.43579712129457127","host":"s3://npm-registry-packages-npm-production"}},"1.4.1":{"_id":"dialog-closedby-polyfill@1.4.1","bugs":{"url":"https://github.com/tak-dcxi/dialog-closedby-polyfill/issues"},"dist":{"shasum":"3f3afc96961b7c7ed7c990439aa8390a7b545b90","tarball":"https://registry.npmjs.org/dialog-closedby-polyfill/-/dialog-closedby-polyfill-1.4.1.tgz","fileCount":11,"integrity":"sha512-0g5zMqieMT3n9yOUWTHH8pDfdshlgnqHVpT3tW2L9/rzF0W3tN65SZJKMXw0xNpdWwZqdPFaNMbLr7ac+YxgsQ==","signatures":[{"sig":"MEQCIFFpxEgkPnDRzF2aSrtpD+hL6YYyP96M6Ds8YmuSv/egAiAC0anJnaNT32KmaQ1/FyAs7w2TDHzB47SlCm8nxUHwUQ==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQCuAlu28S7g3mdUehbQSo/jeDXgCCw46Pfl0cU9eZxPKgIgUrDGRBheDuJzj4WnBWa7XiQXtvCIHL/YRA5irxXhTFo="}],"unpackedSize":47137},"main":"./index.js","name":"dialog-closedby-polyfill","type":"module","types":"./index.d.ts","author":{"url":"https://www.tak-dcxi.com","name":"Takahiro Arai"},"exports":{".":{"import":{"types":"./index.d.ts","default":"./index.js"},"require":{"types":"./index.d.cts","default":"./index.cjs"}},"./fn":{"import":{"types":"./fn.d.ts","default":"./fn.js"},"require":{"types":"./fn.d.cts","default":"./fn.cjs"}},"./package.json":"./package.json"},"gitHead":"ee0dc91e8b6242c764e16c8cec332c7a1307a4a0","license":"MIT","scripts":{"build":"node scripts/build.mjs","typecheck":"tsc --noEmit","prepublishOnly":"npm run typecheck && npm run build"},"version":"1.4.1","_npmUser":{"name":"takahiro_arai","email":"tak.a.dcxi@gmail.com"},"homepage":"https://github.com/tak-dcxi/dialog-closedby-polyfill#readme","keywords":["dialog","closedby","polyfill","html5","web-components"],"repository":{"url":"git+https://github.com/tak-dcxi/dialog-closedby-polyfill.git","type":"git"},"_npmVersion":"11.19.1","description":"Polyfill for the HTMLDialogElement closedBy attribute","directories":{},"maintainers":[{"name":"takahiro_arai","email":"tak.a.dcxi@gmail.com"}],"sideEffects":["./index.js","./index.cjs"],"_nodeVersion":"24.22.2","_hasShrinkwrap":false,"devDependencies":{"esbuild":"^0.25.4","typescript":"^5.0.0","@types/node":"^20.0.0"},"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/dialog-closedby-polyfill_1.4.1_1794844496910_0.42748799512878166"}}},"time":{"created":"2025-05-23T21:55:48.916Z","modified":"2026-11-16T15:54:57.224Z","1.0.0":"2025-05-23T21:55:49.097Z","1.0.1":"2025-05-23T23:27:59.431Z","1.1.0":"2025-05-25T02:03:57.541Z","1.1.1":"2026-02-10T08:17:25.512Z","1.2.0":"2026-02-10T08:19:31.907Z","1.3.0":"2026-02-10T09:39:19.839Z","1.4.0":"2026-11-07T09:38:58.705Z","1.4.1":"2026-11-16T15:54:57.022Z"},"bugs":{"url":"https://github.com/tak-dcxi/dialog-closedby-polyfill/issues"},"author":{"url":"https://www.tak-dcxi.com","name":"Takahiro Arai"},"license":"MIT","homepage":"https://github.com/tak-dcxi/dialog-closedby-polyfill#readme","keywords":["dialog","closedby","polyfill","html5","web-components"],"repository":{"url":"git+https://github.com/tak-dcxi/dialog-closedby-polyfill.git","type":"git"},"description":"Polyfill for the HTMLDialogElement closedBy attribute","maintainers":[{"name":"takahiro_arai","email":"tak.a.dcxi@gmail.com"}],"readme":"# dialog-closedby-polyfill\n\nA polyfill for the HTMLDialogElement `closedby` attribute, providing control over how dialogs can be dismissed.\n\n> **Note**: The HTML attribute is `closedby` (lowercase), while the JavaScript property is `closedBy` (camelCase).\n\n## Features\n\n- 🎯 Implements the `closedby` attribute for `<dialog>` elements\n- 🔒 Three closing modes: `any`, `closerequest`, and `none`\n- 🚀 Zero dependencies\n- 📦 TypeScript support included\n- 🌐 Works in all modern browsers with `<dialog>` support\n- ✨ Automatically detects native support\n\n## Installation\n\n```bash\nnpm install dialog-closedby-polyfill\n```\n\n## Usage\n\nThe polyfill is automatically applied when imported:\n\n```javascript\n// ES Modules (auto-applies if needed)\nimport \"dialog-closedby-polyfill\";\n\n// CommonJS (auto-applies if needed)\nrequire(\"dialog-closedby-polyfill\");\n```\n\n### Manual Control\n\nImporting the package root always applies the polyfill. To decide yourself when (or whether) to apply it, import the side-effect-free `dialog-closedby-polyfill/fn` entry instead:\n\n```javascript\nimport { apply, isSupported } from \"dialog-closedby-polyfill/fn\";\n\nif (!isSupported()) {\n  apply();\n}\n```\n\nBoth entries share the same state, so mixing them never applies the polyfill twice. The package declares `sideEffects`, so bundlers can tree-shake `dialog-closedby-polyfill/fn`.\n\nTo load the polyfill only in browsers that need it, combine both entries with a dynamic import:\n\n```javascript\nimport { isSupported } from \"dialog-closedby-polyfill/fn\";\n\nif (!isSupported()) {\n  await import(\"dialog-closedby-polyfill\");\n}\n```\n\nOr include it via CDN:\n\n```html\n<!-- Polyfill applied automatically -->\n<script\n  type=\"module\"\n  src=\"https://cdn.jsdelivr.net/npm/dialog-closedby-polyfill/index.js\"\n></script>\n\n<!-- polyfill manually -->\n<script type=\"module\">\n  import {\n    isSupported,\n    apply,\n  } from \"https://cdn.jsdelivr.net/npm/dialog-closedby-polyfill/fn.js\";\n  if (!isSupported()) apply();\n</script>\n```\n\n## Demo\n\nhttps://tak-dcxi.github.io/github-pages-demo/closedby.html\n\n## How it works\n\nThe `closedby` attribute controls how a dialog can be dismissed. It applies to modal dialogs (`showModal()`) and modeless dialogs (`show()`) alike, no matter how they were opened – including invoker commands such as `command=\"show-modal\"`.\n\n### Closing Behavior Matrix\n\n| `closedby` value | ESC key | Backdrop / outside click | `close()` method |\n| ---------------- | ------- | ------------------------ | ---------------- |\n| `\"any\"`          | ✅      | ✅                       | ✅               |\n| `\"closerequest\"` | ✅      | ❌                       | ✅               |\n| `\"none\"`         | ❌      | ❌                       | ✅               |\n\nClosing with the ESC key or a backdrop click fires a cancelable `cancel` event first, as in native implementations. Call `event.preventDefault()` in a `cancel` listener to keep the dialog open.\n\nA backdrop click closes the dialog only when the pointer is both pressed and released outside the dialog. A drag that starts inside the dialog and ends on the backdrop, such as a text selection, keeps it open.\n\n### Default behavior (no attribute or an invalid value)\n\nWithout a valid `closedby` value, the dialog uses the *Auto* state defined by the HTML specification:\n\n- Modal dialogs (`showModal()`) behave like `closedby=\"closerequest\"`.\n- Modeless dialogs (`show()`) behave like `closedby=\"none\"`.\n\n`dialog.closedBy` returns the resulting value (`\"closerequest\"` or `\"none\"`), as described on [MDN](https://developer.mozilla.org/en-US/docs/Web/API/HTMLDialogElement/closedBy#default_behavior).\n\n### `closedby=\"any\"`\n\nThe dialog can be closed by:\n\n- Pressing the ESC key\n- Clicking the backdrop\n- Calling the `close()` method\n\n```html\n<dialog\n  id=\"dialog-any\"\n  closedby=\"any\"\n  aria-labelledby=\"dialog-any-title\"\n  autofocus\n>\n  <h1 id=\"dialog-any-title\">any</h1>\n  <p>This dialog can be closed in any way</p>\n  <button type=\"button\" commandfor=\"dialog-any\" command=\"close\">Close</button>\n</dialog>\n```\n\n### `closedby=\"closerequest\"`\n\nThe dialog can be closed by:\n\n- Pressing the ESC key\n- Calling the `close()` method\n- ❌ Clicking the backdrop (disabled)\n\n```html\n<dialog\n  id=\"dialog-closerequest\"\n  closedby=\"closerequest\"\n  aria-labelledby=\"dialog-closerequest-title\"\n  autofocus\n>\n  <h1 id=\"dialog-closerequest-title\">closerequest</h1>\n  <p>This dialog cannot be closed by clicking outside</p>\n  <button type=\"button\" commandfor=\"dialog-closerequest\" command=\"close\">\n    Close\n  </button>\n</dialog>\n```\n\n### `closedby=\"none\"`\n\nThe dialog can only be closed by:\n\n- Calling the `close()` method\n- ❌ Pressing the ESC key (disabled)\n- ❌ Clicking the backdrop (disabled)\n\n```html\n<dialog\n  id=\"dialog-none\"\n  closedby=\"none\"\n  aria-labelledby=\"dialog-none-title\"\n  autofocus\n>\n  <h1 id=\"dialog-none-title\">none</h1>\n  <p>This dialog can only be closed programmatically</p>\n  <button type=\"button\" commandfor=\"dialog-none\" command=\"close\">Close</button>\n</dialog>\n```\n\n## JavaScript API\n\nYou can also set the attribute via JavaScript:\n\n```javascript\nconst dialog = document.querySelector(\"dialog\");\n\n// Using setAttribute\ndialog.setAttribute(\"closedby\", \"none\");\n\n// Using the property (native, or when the polyfill is loaded)\ndialog.closedBy = \"closerequest\";\n\n// Reading returns the computed value\ndialog.removeAttribute(\"closedby\");\ndialog.showModal();\ndialog.closedBy; // \"closerequest\" (Auto state of a modal dialog)\n```\n\nLike the native property, the setter writes the given string to the attribute as is. An invalid value falls back to the Auto state.\n\n## Dynamic Changes\n\nThe `closedby` attribute can be changed while the dialog is open:\n\n```javascript\nconst dialog = document.querySelector(\"dialog\");\ndialog.showModal();\n\n// Change behavior while dialog is open\nsetTimeout(() => {\n  dialog.closedBy = \"none\"; // Now only closeable via close() method\n}, 3000);\n```\n\n## Browser Support\n\nThis polyfill works in all browsers that support the native `<dialog>` element.\n\n**Native `closedby` support:**\n\n- Chrome 134+\n- Safari: Not available in Safari 26.x\n- Firefox: 141+\n- Edge: 134+\n\n**Dialog element support (required for polyfill):**\n\n- Chrome 37+\n- Firefox 98+\n- Safari 15.4+\n- Edge 79+\n\n> **Note**: For browsers without native `closedby` support, this polyfill provides the functionality. For older browsers without `<dialog>` element support, you'll also need a dialog element polyfill.\n\n## API\n\n### Entry points\n\n| Import                        | Side effects                    | Formats            |\n| ----------------------------- | ------------------------------- | ------------------ |\n| `dialog-closedby-polyfill`    | Applies the polyfill if needed  | ESM, CommonJS      |\n| `dialog-closedby-polyfill/fn` | None                            | ESM, CommonJS      |\n\nBoth entries export the same functions.\n\n### Functions\n\n#### `isSupported(): boolean`\n\nCheck if the browser natively supports the `closedby` attribute. The result reflects the browser only: it stays `false` after the polyfill has been applied.\n\n```javascript\nimport { isSupported } from \"dialog-closedby-polyfill/fn\";\n\nif (isSupported()) {\n  console.log(\"Native closedby support available!\");\n}\n```\n\n#### `isPolyfilled(): boolean`\n\nCheck if the polyfill is currently applied.\n\n```javascript\nimport { isPolyfilled } from \"dialog-closedby-polyfill/fn\";\n\nif (isPolyfilled()) {\n  console.log(\"Polyfill has been applied\");\n}\n```\n\n#### `apply(): void`\n\nManually apply the polyfill. Importing `dialog-closedby-polyfill` calls it automatically. It does nothing when the browser supports `closedby` natively or when the polyfill is already active.\n\n```javascript\nimport { apply } from \"dialog-closedby-polyfill/fn\";\n\napply(); // Apply the polyfill\n```\n\n#### `teardown(): void`\n\nTears down the polyfill, removing all event listeners and observers. Useful for cleanup in tests or when dynamically unloading the polyfill. Calling `apply()` afterwards re-activates it.\n\n```javascript\nimport { teardown } from \"dialog-closedby-polyfill/fn\";\n\nteardown(); // Remove all listeners and observers\n```\n\n> **Note**: This does NOT restore the original `showModal`, `show`, or `closedBy` implementations on the prototype. The patched methods stop wiring up listeners until `apply()` is called again.\n\n## TypeScript Support\n\nTypeScript definitions are included for both entries and both module formats. The polyfill extends the `HTMLDialogElement` interface:\n\n```typescript\ninterface HTMLDialogElement {\n  closedBy: \"any\" | \"closerequest\" | \"none\";\n}\n```\n\n## Implementation Details\n\nThe polyfill works by:\n\n1. **Extending HTMLDialogElement**: Adds the `closedBy` property, which computes the same value as the native getter\n1. **Intercepting `showModal()` and `show()`**: Sets up event listeners as soon as a dialog opens\n1. **Observing the `open` attribute**: Uses MutationObserver to catch dialogs opened by other means, such as native invoker commands\n1. **Handling Events**:\n   - `keydown` event for ESC key detection (modeless dialogs get a close request of their own)\n   - `pointerdown` / `pointerup` events for backdrop clicks and clicks outside modeless dialogs, following the light dismiss steps of the HTML specification\n   - `cancel` event, fired before light dismiss and ESC closes the dialog\n   - `close` event for cleanup\n1. **Cleanup**: Removes event listeners when dialog is closed\n\n## Differences from Native Implementation\n\nThis polyfill aims to match the native implementation as closely as possible. However, there might be minor differences in edge cases. Please report any discrepancies you find.\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request.\n\n1. Fork the repository\n2. Create your feature branch (`git checkout -b feature/amazing-feature`)\n3. Commit your changes (`git commit -m 'Add some amazing feature'`)\n4. Push to the branch (`git push origin feature/amazing-feature`)\n5. Open a Pull Request\n\n## License\n\nMIT License - see the [LICENSE](LICENSE) file for details\n\n## Recommended Polyfills\n\n### Invokers Polyfill\n\nDeclarative `command/commandfor` attributes to provide dialog button operations with markup only.\n\n- **GitHub**: [keithamus/invokers-polyfill](https://github.com/keithamus/invokers-polyfill)\n- **Use case**: Simplifies dialog controls without requiring JavaScript event handlers\n\n```html\n<!-- Works seamlessly with this polyfill -->\n<button type=\"button\" commandfor=\"my-dialog\" command=\"show-modal\">\n  Open Dialog\n</button>\n<dialog\n  id=\"my-dialog\"\n  closedby=\"closerequest\"\n  aria-labelledby=\"my-dialog-heading\"\n  autofocus\n>\n  <h1 id=\"my-dialog-heading\">Heading</h1>\n  <p>Content</p>\n  <button type=\"button\" commandfor=\"my-dialog\" command=\"close\">Close</button>\n</dialog>\n```\n\n## Release Notes\n\n### v1.4.1\n\n- **Fixed**: A drag that starts inside a dialog and ends on the backdrop, such as a text selection, no longer closes a `closedby=\"any\"` dialog ([#26](https://github.com/tak-dcxi/dialog-closedby-polyfill/issues/26))\n\n#### Behavior changes\n\nLight dismiss now follows the HTML specification and matches native implementations: it compares where the pointer was pressed (`pointerdown`) and released (`pointerup`).\n\n- The dialog fires `cancel` and closes on `pointerup`, before the `click` event. On touch devices, the `click` that follows a tap on the backdrop reaches the element under the backdrop.\n- Right and middle clicks on the backdrop close the dialog.\n- Synthetic events, such as `dialog.click()`, no longer close the dialog.\n\n### v1.4.0\n\n- **New**: Side-effect-free entry `dialog-closedby-polyfill/fn` for manual and tree-shakeable usage ([#16](https://github.com/tak-dcxi/dialog-closedby-polyfill/issues/16), [#21](https://github.com/tak-dcxi/dialog-closedby-polyfill/issues/21))\n- **New**: CommonJS builds (`index.cjs`, `fn.cjs`) with matching type declarations; `require()` works as documented\n- **New**: ESC closes modeless dialogs with `closedby=\"closerequest\"` or `\"any\"`\n- **Fixed**: Light dismiss now works for dialogs opened with native invoker commands, e.g. in Safari 26 ([#22](https://github.com/tak-dcxi/dialog-closedby-polyfill/issues/22))\n- **Fixed**: Backdrop clicks fire a cancelable `cancel` event before closing, like native implementations ([#17](https://github.com/tak-dcxi/dialog-closedby-polyfill/issues/17))\n- **Fixed**: `isSupported()` no longer returns `true` after the polyfill has been applied ([#15](https://github.com/tak-dcxi/dialog-closedby-polyfill/issues/15), [#21](https://github.com/tak-dcxi/dialog-closedby-polyfill/issues/21))\n- **Fixed**: `apply()` can re-activate the polyfill after `teardown()`\n- **Fixed**: Author calls to `requestClose()` are no longer blocked by `closedby=\"none\"`\n- **Fixed**: A dialog reopened in the same task as it was closed keeps its listeners\n- **Fixed**: Importing in non-DOM runtimes (SSR) no longer throws\n\n#### Behavior changes\n\nThese changes align the polyfill with the HTML specification ([#23](https://github.com/tak-dcxi/dialog-closedby-polyfill/issues/23)). Pages that use a valid `closedby` value are not affected.\n\n- A missing or invalid `closedby` value is now the *Auto* state (modal: `closerequest`, modeless: `none`) instead of `any`. Dialogs with an invalid value, such as `closedby=\"\"`, no longer close on backdrop clicks.\n- `dialog.closedBy` returns the computed value (`\"closerequest\"` or `\"none\"` in the Auto state) instead of `\"any\"`.\n- The `closedBy` setter writes the given value to the attribute as is, without the console warning or the fallback to `any`.\n- The package now declares `\"type\": \"module\"`.\n\n### v1.3.0\n\n- **New**: `teardown()` function to clean up observers and event listeners\n- **New**: Support for modeless dialogs (`show()` method)\n- **New**: Case-insensitive `closedby` attribute handling\n- **Improved**: Internal architecture refactoring\n  - Lazy registration for escape handler\n  - Prevent duplicate observers for the same root\n  - Handle `DOMContentLoaded` for scripts in `<head>`\n\n### v1.2.0\n\n- **Fixed**: Prevent immediate close when reopening dialog after form submission\n  - Added `close` event listener to ensure cleanup regardless of how the dialog was closed\n  - Added `openedAt` timestamp to track when dialog was opened\n  - Use `event.timeStamp` comparison to ignore clicks from before dialog opened\n\n### v1.1.0\n\n- **Fixed**: Using ESC key no longer exits fullscreen mode in Safari/Firefox\n- **Fixed**: Dialog now closes on backdrop click even when `::backdrop` is set to `display: none`\n- **Fixed**: Safari 26.2 false positive detection\n  - Safari 26.2 exposes `closedBy` on `HTMLDialogElement.prototype` but the implementation is incomplete\n  - Changed `isSupported()` to use behavioral test instead of property existence check\n\n### v1.0.0\n\n- Initial release\n- Implements `closedby` attribute polyfill for `<dialog>` elements\n- Three closing modes: `any`, `closerequest`, and `none`\n- TypeScript support included\n\n## Related Links\n\n- [MDN Documentation for closedBy](https://developer.mozilla.org/en-US/docs/Web/API/HTMLDialogElement/closedBy)\n- [Chrome Platform Status](https://chromestatus.com/feature/5097714453725184)\n- [HTML Specification](https://html.spec.whatwg.org/multipage/interactive-elements.html#the-dialog-element)\n\n## Acknowledgments\n\nThis polyfill is inspired by the native implementation and the work of the web standards community.\n\nThanks to everyone who reported issues, reviewed, and contributed fixes, including [@bakura10](https://github.com/bakura10), [@imagoiq](https://github.com/imagoiq), [@RCW679](https://github.com/RCW679), [@TixieSalander](https://github.com/TixieSalander), [@stof](https://github.com/stof), [@lukewarlow](https://github.com/lukewarlow), [@fractaledmind](https://github.com/fractaledmind), [@JawsomeJason](https://github.com/JawsomeJason), and [@hteumeuleu](https://github.com/hteumeuleu).\n","readmeFilename":"README.md"}