From 45e40327441d4e3f9a7129df13f8b30463faee57 Mon Sep 17 00:00:00 2001 From: Keith Cirkel Date: Thu, 5 Oct 2023 09:17:32 +0100 Subject: [PATCH] Add InvokeElement, InvokeEvent, steps for invocation This specifies some of the detail within the Invokers proposal (https://github.com/whatwg/html/issues/9625). This introduces 2 new IDLs: - InvokeEvent: A new event that has `action` and `invoker`. - InvokeElement: A mixin applied to Buttons to add `invokeTargetElement`/`invokeAction` It also adds the `invoketarget` & `invokeaction` attributes which are reflected to the IDL properties. It also adds the steps for invocation: button activation checks if the node has an invokeTarget and dispatches an InvokeEvent if so. Things NOT covered in this commit that are included in the propoal (https://github.com/whatwg/html/issues/9625): - Default per element behaviours (invocation action algorithms), this will be dealt with in subsequent individual commits. - `interestaction` and `interesttarget`. --- source | 248 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 247 insertions(+), 1 deletion(-) diff --git a/source b/source index fca12713fab..657a6eaaafd 100644 --- a/source +++ b/source @@ -46053,6 +46053,8 @@ interface HTMLLabelElement : HTMLElement {
formnovalidate
formtarget
height
+
invoketarget
+
invokeaction
list
max
maxlength
@@ -46718,6 +46720,55 @@ interface HTMLInputElement : HTMLElement { · + + invoketarget + · + · + + · + · + · + · + + + + · + · + · + · + · + + · + Yes + Yes + Yes + + + + invokeaction + · + · + + · + · + · + · + + + + · + · + · + · + · + + · + Yes + Yes + Yes + + + list · @@ -47878,6 +47929,8 @@ interface HTMLInputElement : HTMLElement { formnovalidate, formtarget, height, + invoketarget, + invokeaction, list, max, maxlength, @@ -48020,6 +48073,8 @@ interface HTMLInputElement : HTMLElement { formnovalidate, formtarget, height, + invoketarget, + invokeaction, max, min, multiple, @@ -48123,6 +48178,8 @@ interface HTMLInputElement : HTMLElement { formnovalidate, formtarget, height, + invoketarget, + invokeaction, max, min, multiple, @@ -48228,6 +48285,8 @@ interface HTMLInputElement : HTMLElement { formnovalidate, formtarget, height, + invoketarget, + invokeaction, max, min, multiple, @@ -48499,6 +48558,8 @@ ldh-str = < as defined in formnovalidate, formtarget, height, + invoketarget, + invokeaction, max, min, popovertarget, @@ -48595,6 +48656,8 @@ ldh-str = < as defined in formnovalidate, formtarget, height, + invoketarget, + invokeaction, list, max, min, @@ -48769,6 +48832,8 @@ ldh-str = < as defined in formnovalidate, formtarget, height, + invoketarget, + invokeaction, maxlength, minlength, multiple, @@ -48922,6 +48987,8 @@ ldh-str = < as defined in formnovalidate, formtarget, height, + invoketarget, + invokeaction, maxlength, minlength, multiple, @@ -49079,6 +49146,8 @@ ldh-str = < as defined in formnovalidate, formtarget, height, + invoketarget, + invokeaction, maxlength, minlength, multiple, @@ -49232,6 +49301,8 @@ ldh-str = < as defined in formnovalidate, formtarget, height, + invoketarget, + invokeaction, maxlength, minlength, multiple, @@ -49378,6 +49449,8 @@ ldh-str = < as defined in formnovalidate, formtarget, height, + invoketarget, + invokeaction, maxlength, minlength, multiple, @@ -49543,6 +49616,8 @@ ldh-str = < as defined in formnovalidate, formtarget, height, + invoketarget, + invokeaction, maxlength, minlength, multiple, @@ -49814,6 +49889,8 @@ ldh-str = < as defined in formnovalidate, formtarget, height, + invoketarget, + invokeaction, maxlength, minlength, multiple, @@ -49920,6 +49997,8 @@ ldh-str = < as defined in formnovalidate, formtarget, height, + invoketarget, + invokeaction, max, maxlength, min, @@ -50035,6 +50114,8 @@ ldh-str = < as defined in formnovalidate, formtarget, height, + invoketarget, + invokeaction, list, max, maxlength, @@ -50212,6 +50293,8 @@ ldh-str = < as defined in formnovalidate, formtarget, height, + invoketarget, + invokeaction, list, max, maxlength, @@ -50466,6 +50549,8 @@ ldh-str = < as defined in formnovalidate, formtarget, height, + invoketarget, + invokeaction, list, max, maxlength, @@ -50560,6 +50645,8 @@ ldh-str = < as defined in formmethod, formnovalidate, formtarget, + invoketarget, + invokeaction, popovertarget, and popovertargetaction content attributes; value IDL attribute.

@@ -50830,6 +50917,8 @@ ldh-str = < as defined in
formnovalidate, formtarget, height, + invoketarget, + invokeaction, popovertarget, popovertargetaction, src, and @@ -50953,6 +51042,8 @@ ldh-str = < as defined in apply to the element: + invoketarget, + invokeaction, popovertarget and popovertargetaction.

@@ -51038,6 +51129,8 @@ ldh-str = < as defined in
apply to the element: + invoketarget, + invokeaction, popovertarget and popovertargetaction.

@@ -52619,6 +52712,8 @@ You cannot submit this form when the field is incorrect.
formmethod
formnovalidate
formtarget
+ invoketarget, + invokeaction,
name
popovertarget
popovertargetaction
@@ -52737,7 +52832,10 @@ interface HTMLButtonElement : HTMLElement { -
  • Run the popover target attribute activation behavior given +

  • If element has an invoke target element then run the invoke + target attribute activation behavior given element
  • + +
  • Otherwise, run the popover target attribute activation behavior given element.

  • @@ -78213,6 +78311,46 @@ dictionary ToggleEventInit : EventInit { the oldState attribute. +

    The InvokeEvent interface

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

    This is a freeform hint dictating what action the element must take. + Defaults to "auto".

    +
    + +
    event.invoker
    + +
    +

    Used to identifiy the EventTarget that was interacted with in order to + cause this event.

    +
    + +
    + +

    The action + and attribute must return the value it is initialized to.

    + +

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

    Focus

    @@ -84129,6 +84267,108 @@ dictionary DragEventInit : MouseEventInit { +

    Invokers

    + +

    Introduction

    + + + +

    Buttons are used to control elements on the page, such as + controlling forms. They can be used to control other elements on the page using the invoketarget attribute.

    + +

    HTML elements may have an associated invocation action algorithm + which defines how the element reacts to being invoked. Invocations can vary based on the invokeaction attribute.

    + +

    The invokeaction attribute is a freeform string + that acts as a hint to invocation action algorithms to perform some specific action + such as showing or hiding. It is not enumerated, to allow for userland implementations of an + invocation.

    + +

    The invoke target attributes

    + +

    Buttons may have the following content attributes:

    + + + +

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

    + +

    The invokeaction attribute's missing value default is + the string "auto".

    + + DOM interface: +
    interface mixin InvokeElement {
    +  [CEReactions] attribute Element? invokeTargetElement;
    +  [CEReactions] attribute DOMString invokeAction;
    +};
    + +

    The invokeTargetElement IDL attribute must + reflect the invoketarget attribute.

    + +

    The invokeAction + IDL attribute must reflect the invokeaction + attribute.

    + +

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

    + +
      +
    1. Let invokee be node's invoke target element.

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

    4. + +
    5. Let action be node's invokeaction + attribute

    6. + +
    7. If action is null or empty, then let action be the string "auto".

    8. + +
    9. Let notCancelled be the result of firing an + event named invoke at invokee with its action set to action, its invoker set to node, and its cancelable attribute initialized to true.

    10. + +
    11. If notCancelled is true and invokee has an associated + invocation action algorithm then run the invokee's invocation + action algorithm given action. + +

    + +

    HTML elements may have an associated invocation action algorithm + which defines how the element reacts to being invoked.

    + +

    To get the invoke 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 invokeElement be node's invoketarget-associated element.

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

    10. + +
    11. Return invokeElement.

    12. +

    Loading web pages

    @@ -138445,6 +138685,12 @@ INSERT INTERFACES HERE Form controls Fired at controls during form validation if they do not satisfy their constraints + + invoke + InvokeEvent + Elements + Fired at elements when they handle a user invocation, such as from an invoketarget. + languagechange Event