Repository navigation
fix(gsx): scope := binding names to their templ - #161
Merged
Merged
Conversation
The analyzer collected := binding names for every templ in a file before
rewriting {name} references, so a binding in one templ rewrote a
same-named string parameter in a sibling templ into AddChild and the
generated package failed to build. Rebuild the registry per templ and
rewrite references right after collecting that templ's bindings.
Fixes #155
Contributor
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #161 +/- ##
==========================================
+ Coverage 84.49% 84.51% +0.01%
==========================================
Files 169 169
Lines 21535 21524 -11
==========================================
- Hits 18197 18190 -7
+ Misses 2669 2667 -2
+ Partials 669 667 -2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
letBindings only feeds the per-templ {name} rewrite; the "used" values
were never read. Make it a set and delete the no-op check loop and the
marking blocks in analyzeGoExpr, analyzeGoCode, and analyzeLetBinding.
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.
The analyzer collected
:=element binding names for every templ in a file before rewriting{name}references, so a binding declared in one templ rewrote same-named references in every other templ. A sibling templ with alabel stringparameter was generated asAddChild(label)instead of a text element, and the generated package failed to build.templ A() { label := <span>bound</span> <div>{label}</div> } templ B(label string) { <div>{label}</div> }The binding registry is now rebuilt for each templ, and references are rewritten right after that templ's bindings are collected, so a name only resolves to a bound element inside the templ that declares it. Bindings nested in
ifandforbodies still resolve within their own templ, and two templs binding the same name each keep their own element.Fixes #155