Skip to content

Latest commit

 

History

History
36 lines (29 loc) · 2.13 KB

html-invoker-commands-api.md

File metadata and controls

36 lines (29 loc) · 2.13 KB

The commandfor & command attributes (Invoker Commands API)

New syntax:

<button commandfor="my-modal" command="show-modal">Trigger dialog</button>
<dialog id="my-modal">This is my dialog</dialog>
<div class="counter">
  <button commandfor="num" command="step-down">-</button>
  <input type="number" min="1" id="num" value="1">
  <button commandfor="num" id="btn" command="step-up">+</button>
</div>

Old syntax:

<button invoketarget="my-dialog">This opens a dialog</button>
<dialog id="my-dialog">This is the dialog</dialog>

Adding invoketarget and invokeaction attributes to <button> and <input type="button"> / <input type="reset"> elements would allow authors to assign behaviour to buttons in a more accessible and declarative way, while reducing bugs and simplifying the amount of JavaScript pages are required to ship for interactivity. Buttons with invoketarget will - when clicked, touched, or enacted via keypress - dispatch an InvokeEvent on the element referenced by invoketarget, with some default behaviours.