From 33a85df6e58524fa6c0889b996290238b2277660 Mon Sep 17 00:00:00 2001 From: Keith Cirkel Date: Mon, 26 Jun 2023 18:03:29 +0100 Subject: [PATCH] add dialogmodaltarget attribute --- source | 85 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 83 insertions(+), 2 deletions(-) diff --git a/source b/source index 295577fcfa1..e8fca0233fa 100644 --- a/source +++ b/source @@ -45686,7 +45686,8 @@ interface HTMLInputElement : HTMLElement { // also has obsolete members }; -HTMLInputElement includes PopoverInvokerElement; +HTMLInputElement includes PopoverInvokerElement; +HTMLInputElement includes DialogInvokerElement;
Uses HTMLInputElement.
@@ -52101,7 +52102,8 @@ interface HTMLButtonElement : HTMLElement { readonly attribute NodeList labels; }; -HTMLButtonElement includes PopoverInvokerElement; +HTMLButtonElement includes PopoverInvokerElement; +HTMLButtonElement includes DialogInvokerElement;
Uses HTMLButtonElement.
@@ -60365,6 +60367,85 @@ interface HTMLDialogElement : HTMLElement { +

The dialogmodal target attributes

+ +

Buttons may have the following content attributes:

+ + + +

If specified, the dialogmodaltarget attribute value must + be the ID of a dialog element + in the same tree as the button with the + dialogmodaltarget attribute.

+ +
+

The following shows how the dialogmodaltarget attribute + can be used to show and close a dialog:

+ +
<button dialogmodaltarget="foo">
+  Show a dialog (modal)
+</button>
+
+<dialog id="foo">
+  This is a dialog!
+  <button dialogmodaltarget="foo">Close</button>
+</article>
+
+ + DOM interface: +
interface mixin DialogInvokerElement {
+  [CEReactions] attribute Element? dialogModalTargetElement;
+};
+ +

The dialogModalTargetElement IDL attribute must + reflect the dialogmodaltarget attribute.

+ +

To run the dialog modal target attribute activation behavior given a Node + node:

+ +
    +
  1. Let dialog be node's dialog modal target element.

  2. + +
  3. If dialog is null, then return.

  4. + +
  5. If the open attribute is set on node + then: + +

      +
    1. Run close()

      on node
    2. +
    3. Otherwise, run showModal() on node

    4. +
    + +
  6. +
+ +

To get the dialog modal target element given a Node node, perform + the following steps. They return an HTML element or null.

+ +
    +
  1. If node is not a button, then return + null.

  2. + +
  3. If node is disabled, then return + null.

  4. + +
  5. If node has a form owner and node is a submit button, then return null.

  6. + +
  7. Let dialogElement be node's dialogmodaltarget-associated element.

  8. + +
  9. If dialogElement is null, then return null.

  10. + +
  11. If dialogElement is not a dialog element, then return null.

  12. + +
  13. Return dialogElement.

  14. +
+

The script element