diff --git a/source b/source index f17c3694ad9..9622bca1fd5 100644 --- a/source +++ b/source @@ -13324,6 +13324,7 @@ https://software.hixie.ch/utilities/js/live-dom-viewer/?%3C%21DOCTYPE%20HTML%3E%
  • onchange
  • onclick
  • onclose
  • +
  • oncommand
  • oncontextlost
  • oncontextmenu
  • oncontextrestored
  • @@ -53389,6 +53390,8 @@ You cannot submit this form when the field is incorrect. specified.
    Content attributes:
    Global attributes
    +
    command
    +
    commandfor
    disabled
    form
    formaction
    @@ -53411,6 +53414,8 @@ You cannot submit this form when the field is incorrect. interface HTMLButtonElement : HTMLElement { [HTMLConstructor] constructor(); + [CEReactions] attribute DOMString? command; + [CEReactions] attribute Element? commandForElement; [CEReactions] attribute boolean disabled; readonly attribute HTMLFormElement? form; [CEReactions] attribute USVString formAction; @@ -53475,13 +53480,63 @@ interface HTMLButtonElement : HTMLElement { data-x="attr-button-type-submit-state">Submit Button state, the element is specifically a submit button.

    -
    -

    Constraint validation: If the type attribute is in the Reset Button state or the Button state, the element is barred from constraint validation.

    +

    If specified, the commandfor attribute value must be the ID of an element in the same tree as the button with the commandfor attribute.

    + +

    The command + attribute is an enumerated attribute with the following keywords and states:

    + + + + + + + + + + +
    Keyword + State + Brief description +
    toggle-popover + Toggle popover + Shows or hides the targeted popover element. +
    show-popover + Show popover + Shows the targeted popover element. +
    hide-popover + Hide popover + Hides the targeted popover element. +
    close + Close + Closes the targeted dialog element. +
    show-modal + Show modal + Opens the targeted dialog element as modal. +
    + +

    The attribute's missing value default and invalid value default are both the unknown state.

    + +

    A valid custom command is a string whose first two code points are the U+002D + HYPHEN-MINUS character.

    + +
    +

    A button element element's activation behavior given event is:

    @@ -53492,6 +53547,11 @@ interface HTMLButtonElement : HTMLElement {
  • If element's node document is not fully active, then return.

  • +
  • If element has a form owner and element's commandfor or command attributes are present, + and the element's type attribute is not in + the button state, then return.

  • +
  • If element has a form owner then switch on element's type attribute's state, then:

    @@ -53514,20 +53574,160 @@ interface HTMLButtonElement : HTMLElement {
  • Run the popover target attribute activation behavior given element and event's target.

  • + +
  • Let invokee be the result of running element's get the commandfor associated + element.

  • + +
  • +

    If invokee is not null, then:

    + +
      +
    1. If element has a form owner and element's type attribute is not in the button state, then return.

    2. + +
    3. Let command be element's command attribute.

    4. + +
    5. Let isCustom be true if the command attribute is in the + unknown state, and command's + value is a valid custom command, and false otherwise.

    6. + +
    7. If the command attribute is in the unknown state and isCustom is false, + then return.

    8. + +
    9. Let isPopover be true if invokee's popover attribute is not in the no popover state, and false otherwise.

    10. + +
    11. +

      If isPopover is false and isCustom is false, then:

      + +
        +
      1. Assert: invokee's + namespace is the HTML namespace.

      2. + +
      3. If this standard does not define is valid invoker command steps for + invokee's local name, then + return.

        + +
      4. Otherwise, if the result of running invokee's corresponding is valid + invoker command steps given command is not true, then return.

      5. +
      +
    12. + +
    13. Let continue be the result of firing an + event named command at invokee, using + CommandEvent, with its command + attribute initialized to command's value, its source attribute initialized to element, + and its cancelable and composed attributes initialized to true.

    14. + +
    15. If continue is false, then return.

    16. + +
    17. If isCustom is true, then return.

    18. + +
    19. Let shouldShowPopover be false.

    20. + +
    21. Let shouldHidePopover be false.

    22. + +
    23. +

      If command is in the hidepopover state, then:

      + +
        +
      1. If invokee's popover visibility state is showing, then set shouldHidePopover to + true.

      2. + +
      3. Otherwise return.

      4. +
      +
    24. + +
    25. +

      If command is in the showpopover state, then:

      + +
        +
      1. If invokee's popover visibility state is hidden, then set shouldShowPopover to + true.

      2. + +
      3. Otherwise return.

      4. +
      +
    26. + +
    27. +

      If shouldShowPopover is true and the result of running + check popover validity given invokee, false, false, and null is true, + then:

      + +
        +
      1. Assert: shouldHidePopover is false.

      2. + +
      3. Assert: isPopover is true.

      4. + +
      5. Run the show popover given invokee, false, and + element.

      6. +
      +
    28. + +
    29. +

      Otherwise, if shouldHidePopover is true and the result of running + check popover validity given invokee, true, false, and null is true, + then:

      + +
        +
      1. Assert: shouldShowPopover is false.

      2. + +
      3. Assert: isPopover is true.

      4. + +
      5. Run the hide popover algorithm given invokee, true, true, and + false.

      6. +
      +
    30. + +
    31. +

      Otherwise, if this standard defines invoker command steps for + invokee's local name, then:

      + +
        +
      1. Assert: shouldShowPopover is false and + shouldHidePopover is false.

      2. + +
      3. Run the corresponding invoker command steps given invokee, + element and command.

      4. +
      +
    32. +
    +
  • + +
  • Otherwise, run the popover target attribute activation behavior given + element.

  • + +>>>>>>> ece6a7a9 (Add commandfor & command attributes to HTMLButtonElement) +

    An HTML element can have specific + is valid invoker command steps and invoker command steps defined for the + element's local name.

    +

    The form attribute is used to explicitly associate the button element with its form owner. The name attribute represents the element's name. The disabled attribute is used to make the control non-interactive and - to prevent its value from being submitted. The formaction, - formenctype, disabled attribute is used to make the control non-interactive + and to prevent its value from being submitted. The formaction, formenctype, formmethod, formnovalidate, and formtarget attributes are attributes for form - submission.

    + data-x="attr-fs-formtarget">formtarget attributes are + attributes for form submission.

    The formnovalidate attribute can be used to make submit buttons that do not trigger the constraint validation.

    @@ -53549,10 +53749,16 @@ interface HTMLButtonElement : HTMLElement {

    A button (and its value) is only included in the form submission if the button itself was used to initiate the form submission.

    -
    -
    +

    The commandForElement IDL attribute must + reflect the content attribute of the same name.

    + +

    The command IDL attribute must reflect the + content attribute of the same name.

    +

    The value IDL attribute must reflect the content attribute of the same name.

    @@ -53584,8 +53790,52 @@ interface HTMLButtonElement : HTMLElement {
    +
    +

    The following buttons use commandfor to open and close a popover box when activated:

    +
    <button type=button
    +        commandfor="the-popover"
    +        command="toggle-popover">
    + Show menu
    +</button>
    +<div popover
    +     id="the-popover">
    + <button commandfor="the-popover"
    +         command="hide-popover">
    +  Hide menu
    + </button>
    +</div>
    +    
    +
    +
    +

    The following buttons use commandfor with a custom command on an element, demonstrating how + one could utilise custom commands for unspecified behavior:

    + +
    <button type=button
    +        commandfor="the-image"
    +        command="--rotate-left">
    + Rotate Left
    +</button>
    +<button type=button
    +        commandfor="the-image"
    +        command="--rotate-right">
    + Rotate Right
    +</button>
    +<img id="the-image"
    +     src="photo.jpg">
    +<script>
    +  const image = document.getElementById("the-image");
    +  image.addEventListener("command", (event) => {
    +   if ( event.command == "--rotate-left" ) {
    +    event.target.style.rotate = "-90deg"
    +   } else if ( event.command == "--rotate-right" ) {
    +    event.target.style.rotate = "90deg"
    +   }
    +  });
    +</script>
    +    
    +

    The select element

    @@ -61861,49 +62111,56 @@ interface HTMLDialogElement : HTMLElement { data-x="dom-dialog-showModal">showModal() method steps are:

      -
    1. If this has an open attribute and the - is modal flag of this is true, then return.

    2. +
    3. Show this as modal.

    4. +
    -
  • If this has an open attribute, then - throw an "InvalidStateError" DOMException.

  • +

    When a dialog element subject is to be shown as modal, run these steps:

    -
  • If this's node document is not fully active, then +

      +
    1. If subject has an open attribute and + the is modal flag of subject is true, then return.

    2. + +
    3. If subject has an open attribute, then throw an "InvalidStateError" DOMException.

    4. -
    5. If this is not connected, then throw an +

    6. If subject's node document is not fully active, + then throw an "InvalidStateError" DOMException.

    7. + +
    8. If subject is not connected, then throw an "InvalidStateError" DOMException.

    9. -
    10. If this is in the popover showing - state, then throw an "InvalidStateError" - DOMException.

    11. +
    12. If subject is in the popover showing state, then throw an + "InvalidStateError" DOMException.

    13. If the result of firing an event named beforetoggle, using ToggleEvent, with the cancelable attribute initialized to true, the oldState attribute initialized to "closed", and the newState - attribute initialized to "open" at this is false, then + attribute initialized to "open" at subject is false, then return.

    14. -
    15. If this has an open attribute, +

    16. If subject has an open attribute, then return.

    17. -
    18. If this is not connected, then return.

    19. +
    20. If subject is not connected, then return.

    21. -
    22. If this is in the popover showing - state, then return.

    23. +
    24. If subject is in the popover showing state, then return.

    25. Queue a dialog toggle event task given subject, "closed", and "open".

    26. -
    27. Add an open attribute to this, whose +

    28. Add an open attribute to subject, whose value is the empty string.

    29. -
    30. Set the is modal flag of this to true.

    31. +
    32. Set the is modal flag of subject to true.

    33. -

      Let this's node document be blocked by the modal dialog this.

      +

      Let subject's node document be blocked by the modal dialog subject.

      This will cause the focused area of the document to become inert (unless that currently focused area is a @@ -61913,41 +62170,41 @@ interface HTMLDialogElement : HTMLElement { focus.

    34. -
    35. If this's node document's top layer does not - already contain this, then add an element - to the top layer given this.

    36. +
    37. If subject's node document's top layer does not + already contain subject, then add an element + to the top layer given subject.

    38. -

      Set this's close watcher to the +

      Set subject's close watcher to the result of establishing a close watcher given - this's relevant global object, with:

      + subject's relevant global object, with:

      • cancelAction given canPreventClose being to return the result of firing an event named cancel at this, with the cancel at subject, with the cancelable attribute initialized to canPreventClose.

      • closeAction being to close the - dialog given this and null.

      • + dialog given subject and null.

    39. -
    40. Set this's previously focused element to the +

    41. Set subject's previously focused element to the focused element.

    42. Let hideUntil be the result of running topmost popover ancestor - given this, null, and false.

    43. + given subject, null, and false.

      -
    44. If hideUntil is null, then set hideUntil to this's +

    45. If hideUntil is null, then set hideUntil to subject's node document.

    46. Run hide all popovers until given hideUntil, false, and true.

    47. -
    48. Run the dialog focusing steps given this.

    49. +
    50. Run the dialog focusing steps given subject.

    The dialog focusing steps, given a dialog element subject, @@ -61989,6 +62246,78 @@ interface HTMLDialogElement : HTMLElement {

  • Set topDocument's autofocus processed flag to true.

  • +

    The is valid invoker command steps, given a dialog element + subject and command, are:

    + +
      +
    1. If command is in the close state, then return true.

    2. + +
    3. If command is in the show modal state, then return true.

      +
    4. + +
    5. Return false.

    6. +
    + +

    The invoker command steps, given a dialog element + invokee, invoker, and command, are:

    + +
      +
    1. If invokee is in the popover showing state, then return.

    2. + +
    3. +

      If command is in the close state, then:

      + +
        +
      1. If invokee has an open attribute, then:

        + +
          +
        1. Let value be invoker's value

        2. + +
        3. Close the dialog invokee with value.

        4. +
        +
      +
    4. + +
    5. +

      If command is in the show modal state, then:

      + +
        +
      1. If invokee does not have an open + attribute, then show modal dialog invokee.

      2. +
      +
    6. +
    + +
    +

    The following buttons use commandfor to open and close a "confirm" dialog as modal when + activated:

    + +
    <button type=button
    +        commandfor="the-dialog"
    +        command="show-modal">
    + Delete
    +</button>
    +<dialog id="the-dialog">
    + <form action="/delete" method="POST">
    +  <button type="submit">
    +   Delete
    +  </button>
    +  <button commandfor="the-dialog"
    +          command="close">
    +   Cancel
    +  </button>
    + </form>
    +</dialog>
    +    
    +
    +

    The dialog HTML element removing steps, given removedNode and oldParent, are:

    @@ -62007,8 +62336,9 @@ interface HTMLDialogElement : HTMLElement {
  • If removedNode's node document's top layer contains removedNode, then remove an element from - the top layer immediately given removedNode.

  • + data-x="list contains">contains removedNode, then + remove an element from the top layer immediately given removedNode.

    +
  • Set the is modal flag of removedNode to false.

  • @@ -62022,8 +62352,9 @@ interface HTMLDialogElement : HTMLElement {
  • Close the dialog this with returnValue.

  • -

    When a dialog element subject is to be closed, with null or a string result, run these steps:

    +

    When a dialog element subject is to be closed, with null or a string result, run these + steps:

    1. If subject does not have an open @@ -62044,11 +62375,12 @@ interface HTMLDialogElement : HTMLElement {

    2. Remove subject's open attribute.

    3. -
    4. If the is modal flag of subject is true, then request an - element to be removed from the top layer given subject.

    5. +
    6. If the is modal flag of subject is true, then + request an element to be removed from the top layer given subject.

      +
    7. -
    8. Let wasModal be the value of subject's is - modal flag.

    9. +
    10. Let wasModal be the value of subject's + is modal flag.

    11. Set the is modal flag of subject to false.

    12. @@ -62072,13 +62404,13 @@ interface HTMLDialogElement : HTMLElement {
    -
  • Queue an element task on the user interaction task source given the - subject element to fire an event named +

  • Queue an element task on the user interaction task source given + the subject element to fire an event named close at subject.

  • -

    If subject's close watcher is not null, - then:

    +

    If subject's close watcher is not + null, then:

    1. Destroy subject's ToggleEventInit : EventInit { the oldState attribute. +

      The CommandEvent interface

      + +
      [Exposed=Window]
      +interface CommandEvent : Event {
      +  constructor(DOMString type, optional CommandEventInit eventInitDict = {});
      +  readonly attribute Element? source;
      +  readonly attribute DOMString action;
      +};
      +
      +dictionary CommandEventInit : EventInit {
      +  Element? source = null;
      +  DOMString action = "auto";
      +};
      + +
      +
      event.command
      + +
      +

      Returns what action the element can take.

      +
      + +
      event.source
      + +
      +

      Returns the Element that was interacted with in order to cause this event.

      +
      +
      + +

      The command attribute must return the value it as + initialized to.

      + +

      The source getter steps are to + return the result of retargeting source against this's currentTarget.

      Focus

      @@ -86550,7 +86921,6 @@ dictionary DragEventInit : MouseEventInit {
    -

    Loading web pages

    @@ -113383,6 +113753,7 @@ typedef OnBeforeUnloadEventHandlerNonNull? OnBeforeUnl onchange change onclick click onclose close + oncommand command oncontextlost contextlost oncontextmenu contextmenu oncontextrestored contextrestored @@ -113555,6 +113926,7 @@ typedef OnBeforeUnloadEventHandlerNonNull? OnBeforeUnl attribute EventHandler onchange; attribute EventHandler onclick; attribute EventHandler onclose; + attribute EventHandler oncommand; attribute EventHandler oncontextlost; attribute EventHandler oncontextmenu; attribute EventHandler oncontextrestored; @@ -142509,6 +142881,22 @@ interface External { script Integrity metadata used in Subresource Integrity checks SRI Text + + command + button + Indicates to the targeted element which action to take. + "toggle-popover"; + "show-popover"; + "hide-popover"; + "close"; + "show-modal"; + a valid custom command; + the empty string + + commandfor + button + Targets another element to be invoked. + ID* is HTML elements @@ -143226,6 +143614,12 @@ interface External { close event handler Event handler content attribute + + oncommand + HTML elements + command event handler + Event handler content attribute + oncontextlost HTML elements @@ -144233,6 +144627,13 @@ INSERT INTERFACES HERE CloseWatcher, dialog elements, MessagePort Fired at CloseWatcher objects or dialog elements when they are closed via a close request or via web developer code, or at MessagePort objects when disentangled + + command + CommandEvent + Elements + Fired at elements when they handle a user invocation, via a commandfor attribute. + connect MessageEvent