-
Notifications
You must be signed in to change notification settings - Fork 235
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add no-action-on-submit-button rule documentation
- Loading branch information
Joao
committed
Aug 13, 2021
1 parent
ed5a054
commit 0bbe945
Showing
2 changed files
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# no-action-on-submit-button | ||
|
||
This rule requires all `<button>` elements with a `type="submit"` attribute to not have any action. | ||
|
||
When the `type` attribute of `<button>` elements is `submit`, the action should be on the `<form>` element instead of directly on the button. | ||
|
||
By default, the `type` attribute of `<button>` elements is `submit`. | ||
|
||
## Examples | ||
|
||
This rule **forbids** the following: | ||
|
||
```hbs | ||
<button type="submit" {{on "click" "handleClick"}} /> | ||
<button type="submit" {{action "handleClick"}} /> | ||
<button {{on "click" "handleClick"}} /> | ||
<button {{action "handleClick"}} /> | ||
``` | ||
|
||
This rule **allows** the following: | ||
|
||
```hbs | ||
<button type="button" {{on "click" "handleClick"}} /> | ||
<button type="button" {{action "handleClick"}} /> | ||
<button type="submit" /> | ||
<button /> | ||
``` | ||
|
||
## Related Rules | ||
|
||
- [require-button-type](require-button-type.md) | ||
|
||
## References | ||
|
||
- Red [HTML spec - the button element](https://html.spec.whatwg.org/multipage/form-elements.html#attr-button-type) |