A modal dialog that's opened with
https://github.com/github/details-dialog-element/compare/v3.0.8...v3.0.9
A modal dialog that's opened with a <details> button.
$ npm install --save @github/details-dialog-element
import '@github/details-dialog-element'
<details>
<summary>Open dialog</summary>
<details-dialog>
Modal content
<button type="button" data-close-dialog>Close</button>
</details-dialog>
</details>
Dialog content can be loaded from a server by embedding an <include-fragment>
element.
<details>
<summary>Robots</summary>
<details-dialog src="/robots" preload>
<include-fragment>Loading…</include-fragment>
</details-dialog>
</details>
The src
attribute value is copied to the <include-fragment>
the first time the <details>
button is toggled open, which starts the server fetch.
If the preload
attribute is present, hovering over the <details>
element will trigger the server fetch.
details-dialog-close
details-dialog-close
event is fired from <details-dialog>
when a request to close the dialog is made from
summary, [data-close-dialog]
, ordialog.toggle(false)
This event bubbles, and can be canceled to keep the dialog open.
document.addEventListener('details-dialog-close', function(event) {
if (!confirm('Are you sure?')) {
event.preventDefault()
}
})
Browsers without native custom element support require a polyfill.
npm install
npm test
Distributed under the MIT license. See LICENSE for details.
npm update
229d2b9https://github.com/github/details-dialog-element/compare/v3.0.6...v3.0.7
details-dialog:will-close
-> details-dialog-close
#28preload
/autofocus
fixes #32Custom dialog element to be used with <details>
Custom dialog element to be used with <details>