shelving 1.295.1 → 1.295.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shelving",
3
- "version": "1.295.1",
3
+ "version": "1.295.2",
4
4
  "author": "Dave Houlbrooke <dave@shax.com>",
5
5
  "repository": {
6
6
  "type": "git",
@@ -40,11 +40,12 @@ function _closeOnBackdropClick({ currentTarget, target }) {
40
40
  if (target instanceof Element && target.closest("a:any-link, nav button:enabled"))
41
41
  _requestClose(currentTarget);
42
42
  }
43
- /** Ask a `<dialog>` to close. `requestClose()` fires a cancelable `cancel` event, so `<Dialog>` can run `onClose` in a transition. Older browsers close at once. */
43
+ /**
44
+ * Ask a `<dialog>` to close: fire a cancelable `cancel` event, so `<Dialog>` can run `onClose` in a transition. Close it at once only when nothing cancels the event.
45
+ * - Not `requestClose()`: some browsers lack it, and Safari fires its `cancel` event as not cancelable. Both close the dialog at once, so it vanishes with no fade.
46
+ */
44
47
  function _requestClose(dialog) {
45
- if (typeof dialog.requestClose === "function")
46
- dialog.requestClose();
47
- else
48
+ if (dialog.dispatchEvent(new Event("cancel", { cancelable: true })))
48
49
  dialog.close();
49
50
  }
50
51
  /**
@@ -74,10 +74,12 @@ function _closeOnBackdropClick({ currentTarget, target }: MouseEvent<HTMLDialogE
74
74
  if (target instanceof Element && target.closest("a:any-link, nav button:enabled")) _requestClose(currentTarget);
75
75
  }
76
76
 
77
- /** Ask a `<dialog>` to close. `requestClose()` fires a cancelable `cancel` event, so `<Dialog>` can run `onClose` in a transition. Older browsers close at once. */
77
+ /**
78
+ * Ask a `<dialog>` to close: fire a cancelable `cancel` event, so `<Dialog>` can run `onClose` in a transition. Close it at once only when nothing cancels the event.
79
+ * - Not `requestClose()`: some browsers lack it, and Safari fires its `cancel` event as not cancelable. Both close the dialog at once, so it vanishes with no fade.
80
+ */
78
81
  function _requestClose(dialog: HTMLDialogElement): void {
79
- if (typeof dialog.requestClose === "function") dialog.requestClose();
80
- else dialog.close();
82
+ if (dialog.dispatchEvent(new Event("cancel", { cancelable: true }))) dialog.close();
81
83
  }
82
84
 
83
85
  /**