@@ -80,9 +80,8 @@ the balance.
80
80
` Space ` or ` Enter ` (Carriage Return) key on the keyboard. For other HIDs such
81
81
as eye tracking or pedals or game controllers, the equivalent expected "click"
82
82
action should be used to invoke the element.
83
- - Invoker: An invoker is a button element (that is a ` <button> ` ,
84
- ` <input type="button"> ` , or ` <input type="reset"> ` ) that has an ` commandfor `
85
- and ` command ` attribute set.
83
+ - Invoker: An invoker is a button control (that is a ` <button type="button"> ` ) that has a
84
+ ` commandfor ` and ` command ` attribute set.
86
85
- Invoker Target: An element which is referenced to by an Invoker, via the
87
86
` commandfor ` attribute.
88
87
@@ -167,7 +166,7 @@ When pointing to a `popover`, `commandfor` acts much like `popovertarget`,
167
166
allowing the toggling of popovers.
168
167
169
168
``` html
170
- <button commandfor =" my-popover" command =" toggle-popover" >Open Popover</button >
169
+ <button type = " button " commandfor =" my-popover" command =" toggle-popover" >Open Popover</button >
171
170
<!-- Effectively the same as popovertarget="my-popover" -->
172
171
173
172
<div id =" my-popover" popover =" auto" >Hello world</div >
@@ -179,12 +178,12 @@ When pointing to a `<dialog>`, `command` can toggle a `<dialog>`'s
179
178
openness.
180
179
181
180
``` html
182
- <button commandfor =" my-dialog" command =" show-modal" >Open Dialog</button >
181
+ <button type = " button " commandfor =" my-dialog" command =" show-modal" >Open Dialog</button >
183
182
184
183
<dialog id =" my-dialog" >
185
184
Hello world!
186
185
187
- <button commandfor =" my-dialog" command =" close" >Close</button >
186
+ <button type = " button " commandfor =" my-dialog" command =" close" >Close</button >
188
187
</dialog >
189
188
```
190
189
@@ -196,7 +195,7 @@ When pointing to a `<details>`, `commandfor` can toggle a `<details>`'
196
195
openness.
197
196
198
197
``` html
199
- <button commandfor =" my-details" command =" open" >Open Details</button >
198
+ <button type = " button " commandfor =" my-details" command =" open" >Open Details</button >
200
199
<!-- Can be used to replicate the `<summary>` interaction -->
201
200
202
201
<details id =" my-details" >
@@ -214,7 +213,7 @@ rendered button _within_ the input; and can be used to declare a customised
214
213
alternative button to the input's button.
215
214
216
215
``` html
217
- <button commandfor =" my-file" command =" show-picker" >Pick a file...</button >
216
+ <button type = " button " commandfor =" my-file" command =" show-picker" >Pick a file...</button >
218
217
219
218
<input id =" my-file" type =" file" />
220
219
```
@@ -228,8 +227,8 @@ shines, allowing multiple buttons to handle different interactions with the
228
227
video player.
229
228
230
229
``` html
231
- <button commandfor =" my-video" command =" play-pause" >Play/Pause</button >
232
- <button commandfor =" my-video" command =" toggle-muted" >Mute/Unmute</button >
230
+ <button type = " button " commandfor =" my-video" command =" play-pause" >Play/Pause</button >
231
+ <button type = " button " commandfor =" my-video" command =" toggle-muted" >Mute/Unmute</button >
233
232
234
233
<video id =" my-video" ></video >
235
234
```
@@ -242,7 +241,7 @@ manual event handlers to the Invokers.
242
241
243
242
``` html
244
243
<!-- Custom commands must contain a double dash! -->
245
- <button commandfor =" my-custom" command =" --my-frobulate" >Frobulate</button >
244
+ <button type = " button " commandfor =" my-custom" command =" --my-frobulate" >Frobulate</button >
246
245
247
246
<div id =" my-custom" ></div >
248
247
@@ -579,7 +578,7 @@ As the underlying system for invoke elements uses event dispatch, Custom Element
579
578
can make use of ` CommandEvent ` for their own behaviours. Consider the following:
580
579
581
580
``` html
582
- <button commandfor =" my-element" command =" --spin-widget" >
581
+ <button type = " button " commandfor =" my-element" command =" --spin-widget" >
583
582
Spin the widget
584
583
</button >
585
584
@@ -696,7 +695,7 @@ fullscreen may now declare a button that can fullscreen. Consider the following:
696
695
``` html
697
696
<iframe sandbox allow =" fullscreen" >
698
697
<html id =" invokee" >
699
- <button commandfor =" invokee" command =" toggleFullscreen" >Invoke</button >
698
+ <button type = " button " commandfor =" invokee" command =" toggleFullscreen" >Invoke</button >
700
699
<button onclick =" invokee.requestFullscreen()" >Go fullscreen</button >
701
700
</html >
702
701
</iframe >
@@ -810,29 +809,25 @@ for non-interactive elements. While `<a>`s _are_ interactive, they should _only_
810
809
be used for page navigation and not for invoking other behaviours, and so
811
810
`command`/`commandfor` should not be allowed.
812
811
813
- #### Why isn't `input [type=submit]` included?
812
+ #### Why isn't `button [type=submit]` included?
814
813
815
814
This is not added by design. Submit inputs already have a default action:
816
815
submitting forms. If you want a button to control the submission of a form, use
817
- `input [type=submit]`, if you want a button to control invocation of something
818
- _other_ than a form then you should use `input [type=button]`.
816
+ `button [type=submit]`, if you want a button to control invocation of something
817
+ _other_ than a form then you should use `button [type=button]`.
819
818
820
- #### Why _is_ `input [type=reset]` included?
819
+ #### Why isn't `button [type=reset]` included?
821
820
822
- It may stand to reason that if `input[type=submit]` is _excluded_ then so should
823
- `input[type=reset]`, however, there are valid use cases to resetting a form at
824
- the same time as some other action, for example closing the dialog that contains
825
- a form:
821
+ This is not added by design. Reset inputs already have a default action:
822
+ resetting forms. If you want a button to control the resetting of a form, use
823
+ `button[type=reset]`, if you want a button to control invocation of something
824
+ _other_ than a form then you should use `button[type=button]`.
826
825
827
- ```html
828
- <dialog id =" my-dialog" >
829
- <form >
830
- <input type =" text" />
831
- <!-- This button closes the dialog _and_ resets the form -->
832
- <input type =" reset" commandfor =" my-dialog" command =" close" value =" Cancel" />
833
- </form >
834
- </dialog >
835
- ```
826
+ #### Why isn't `input[type=button]` included?
827
+
828
+ This is not added by design. `input[type=button]` is a legacy element,
829
+ use of this element is discouraged in favour of `<button >`. So we only support
830
+ `<button >` elements.
836
831
837
832
#### What does this mean for `popovertarget`?
838
833
@@ -854,7 +849,7 @@ methods, if that's desired:
854
849
855
850
856
851
```html
857
- <button commandfor =" my-element" command =" --spin-widget" >
852
+ <button type = " button " commandfor =" my-element" command =" --spin-widget" >
858
853
Spin the widget
859
854
</button >
860
855
@@ -888,9 +883,9 @@ you feel it necessary you can invent your own DSLs for passing extra data using
888
883
this hint. For example:
889
884
890
885
``` html
891
- <button commandfor =" my-counter" command =" --add-1" >Add 1</button >
892
- <button commandfor =" my-counter" command =" --add-2" >Add 2</button >
893
- <button commandfor =" my-counter" command =" --add-10" >Add 10</button >
886
+ <button type = " button " commandfor =" my-counter" command =" --add-1" >Add 1</button >
887
+ <button type = " button " commandfor =" my-counter" command =" --add-2" >Add 2</button >
888
+ <button type = " button " commandfor =" my-counter" command =" --add-10" >Add 10</button >
894
889
895
890
<input readonly id =" my-counter" value =" 0" />
896
891
@@ -909,9 +904,9 @@ You can also leverage the buttons `value` attribute to effectively parameterise
909
904
certain commands:
910
905
911
906
``` html
912
- <button commandfor =" my-counter" command =" --add-num" value =" 1" >Add 1</button >
913
- <button commandfor =" my-counter" command =" --add-num" value =" 2" >Add 2</button >
914
- <button commandfor =" my-counter" command =" --add-num" value =" 10" >Add 10</button >
907
+ <button type = " button " commandfor =" my-counter" command =" --add-num" value =" 1" >Add 1</button >
908
+ <button type = " button " commandfor =" my-counter" command =" --add-num" value =" 2" >Add 2</button >
909
+ <button type = " button " commandfor =" my-counter" command =" --add-num" value =" 10" >Add 10</button >
915
910
916
911
<input readonly id =" my-counter" value =" 0" />
917
912
@@ -924,3 +919,5 @@ certain commands:
924
919
});
925
920
</script >
926
921
```
922
+
923
+ You could also use ` data-* ` attributes for even more granular control.
0 commit comments