Skip to content

Commit

Permalink
clarified code example: removed unnecessary button type (#38157)
Browse files Browse the repository at this point in the history
The code example was misleading (Exhibit A: I was misled by it). How so:
- The button type attribute is known to carry behavior w.r.t. its ancestor element (button.type=submit will submit a <form> etc. ; see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#type )
- The documentation page is all about closing a <dialog> and raising the cancel event.
- The presence of a <button type="reset"> in the example suggests that the type attribute does actually contribute to the button behavior w.r.t. the <dialog>
- but it does nothing, the closing of the dialog is only the result of a click listener attached via script
  • Loading branch information
teetotum authored Feb 14, 2025
1 parent 7f29fef commit 9ba2221
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ A generic {{domxref("Event")}}.

```html
<dialog class="example-dialog">
<button class="close" type="reset">Close</button>
<button class="close">Close</button>
</dialog>

<button class="open-dialog">Open dialog</button>
Expand Down

0 comments on commit 9ba2221

Please sign in to comment.