examples: use provided h helpers instead of raw h.Attr#105
Merged
Conversation
Make the example apps (and the viashowcase flagship) model idiomatic use of the typed attribute helpers rather than the stringly-typed h.Attr escape hatch. All swaps are behavior-preserving — each helper emits the identical attribute: - aria-* → h.Aria(name, val) - autocomplete/alt/method/action → h.AutoComplete/Alt/Method/Action - required/checked (boolean) → h.Required()/h.Checked() - maxlength → h.MaxLength(int); width → h.Width (enctype/accept/autofocus/readonly keep h.Attr — no shorthand exists.) Root build + tests and the viashowcase module both green.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #104: make the example apps demonstrate effective, idiomatic use of the typed
hhelpers rather than the stringly-typedh.Attrescape hatch.A sweep of all 14
internal/examples/*apps + theviashowcaseflagship found the examples were mostly clean already; the remaining hand-rolled attributes now have provided helpers. All swaps are behavior-preserving — each helper emits the byte-identical attribute:h.Attr("aria-…", v)→h.Aria(name, v)h.Attr("autocomplete"/"alt"/"method"/"action", v)→h.AutoComplete/Alt/Method/Action(v)h.Attr("required")/h.Attr("checked")→h.Required()/h.Checked()h.Attr("maxlength", "60")→h.MaxLength(60);h.Attr("width", …)→h.Width(…)enctype/accept/autofocus/readonlykeeph.Attr(no shorthand exists).Verified: root
go build ./...+go test -race ./...green; theviashowcasemodule builds, vets, and tests green. No behavior change.