fix(button): separate custom attributes from role - #2118
Merged
Conversation
The range over `attributes` emitted each pair with a leading space, but its closing `-}}` swallowed the newline before role="button". A button with a custom attribute therefore rendered `download="x"role="button"`. Browsers recover from the missing separator, but the markup is invalid. Use the one-line form already applied in assets/nav.html and shortcodes/button-group.html: the separator sits outside the printf, so the whitespace ahead of role="button" survives. Buttons without custom attributes are unaffected. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
✅ Deploy Preview for gethinode-demo ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Collaborator
Author
|
🎉 This PR is included in version 3.18.2 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
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.
Summary
assets/button.htmlrendered customattributesglued to theroleattribute that follows them:
The
rangeblock emitted each pair with a leading space inside theprintf, but its closing{{- end -}}trimmed the newline separating thelast attribute from
role="button". Browsers recover from the missingseparator, so the button still works, but the markup is invalid and any
consumer parsing the tag strictly sees a single mangled attribute.
Fix
Switch to the one-line form already used in
assets/nav.htmlandshortcodes/button-group.html, which keeps the separator outside theprintfand leaves the trailing whitespace intact:assets/button.htmlwas the only partial with this bug;nav.htmlandbutton-group.htmlwere already correct.Test plan
Verified against a live site (infusal.io) by patching its vendored copy of
the partial and rebuilding:
attributes(dict "download" "odcs-json-schema-v3.0.1.json")now renders
download="…"androle="button"as separate attributes.range emitted nothing before and after.
pnpm test(lint +test:templates) passes.🤖 Generated with Claude Code