Validates that rendered button tags define a valid type attribute.
This check inspects rendered <button> elements and flags buttons without a
type attribute, or with a type value other than button, submit, or
reset.
Examples
Bad:
<button phx-click="save">Save</button>Why this is bad:
Browsers default <button> elements to submit buttons, which can submit an
enclosing form when the button was meant to run a local action.
Better:
<button type="button" phx-click="save">Save</button>Why this is better:
The button behavior is explicit and does not depend on the browser default.
Bad:
<button type="save">Save</button>Why this is bad:
Invalid button types are treated inconsistently by readers and tools.
Better:
<button type="submit">Save</button>Why this is better:
The rendered markup uses one of the button types recognized by browsers.
Options
This check has no check-specific options. Add the module directly to the explicit checks list:
Bylaw.HTML.Check.RequireButtonTypeUsage
Add this module to the explicit check list passed through Bylaw.HTML.
See Bylaw.HTML for the full rendered HTML validation setup.
Summary
Functions
Implements the Bylaw.HTML.Check validation callback.
Functions
@spec validate(Bylaw.HTML.Check.context()) :: Bylaw.HTML.Check.result()
Implements the Bylaw.HTML.Check validation callback.