Open
Description
Describe the problem
Native <dialog>
elements support now two methods to close it:
close()
requestClose()
- triggerscancel
event allowing to stop the closing
The latter is a new addition but seems to be available on all browsers:
https://developer.mozilla.org/en-US/docs/Web/API/HTMLDialogElement/requestClose
Svelte does not define that function yet:
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLDialogElement) */
interface HTMLDialogElement extends HTMLElement {
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLDialogElement/open) */
open: boolean;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLDialogElement/returnValue) */
returnValue: string;
/**
* Closes the dialog element.
*
* The argument, if provided, provides a return value.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLDialogElement/close)
*/
close(returnValue?: string): void;
/**
* Displays the dialog element.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLDialogElement/show)
*/
show(): void;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLDialogElement/showModal) */
showModal(): void;
addEventListener<K extends keyof HTMLElementEventMap>(type: K, listener: (this: HTMLDialogElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
removeEventListener<K extends keyof HTMLElementEventMap>(type: K, listener: (this: HTMLDialogElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
}
Describe the proposed solution
Add the method requestClose
to HTMLDialogElement
:
/*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLDialogElement/requestClose)
*/
requestClose(returnValue?: string): void;
Importance
nice to have
Metadata
Metadata
Assignees
Labels
No labels