Engine: Key a collection whose rows are built by a tag helper - #2271
Merged
Conversation
|
View your CI Pipeline Execution ↗ for commit 9483ba6
💡 Verify your cache is correct by running tasks in a sandbox. Read docs ↗ ☁️ Nx Cloud last updated this comment at |
🌿 Interactive Playground and Documentation PreviewA preview deployment has been built for this pull request. Try out the changes live in the interactive playground: 🌱 Grown from commit ✅ Preview deployment has been cleaned up. |
commit: |
`<%= tag.li id: person[:id] do %>` produces the same HTML as `<li id="...">` but lost keying
entirely, so the collection fell back to index keying and emitted no row markers at all.
Parsed with `action_view_helpers`, a tag helper is already an element whose open tag is ERB and
whose keyword arguments are real attributes, so the key is there to be read:
HTMLElementNode
ERBOpenTagNode
HTMLAttributeNode
HTMLAttributeNameNode -> LiteralNode "id"
HTMLAttributeValueNode -> RubyLiteralNode "person[:id]"
`SlotVisitor` refused to read it in two places. `attributes_for` bailed unless the open tag was an
`HTMLOpenTagNode`, so it found no attributes on a helper's element, and `key_parts_for` knew about
`ERBContentNode` and `LiteralNode` but not `RubyLiteralNode`, which is what a keyword argument
holds where a written attribute holds ERB.
That parse is also what stops a helper taking a block from being marked as a block with markers
inside it, which is a slot whose value is used, so the option is required rather than recommended.
(cherry picked from commit d4689eee5f54c4b14e73beee97e77a834622d376)
(cherry picked from commit 3ca7fa0)
marcoroth
force-pushed
the
slots/keying
branch
from
August 18, 2026 02:57
f0c9ffc to
9483ba6
Compare
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.
This pull request fixes a collection losing its keying when its rows are built by a tag helper.
produces the same HTML as
<li id="...">, but the collection fell back to index keying and emitted no row markers at all, so nothing about that collection could be updated a row at a time.Parsed with
action_view_helpers, a tag helper is already an element whose open tag is ERB and whose keyword arguments are real attributes, so the key is there to be read:SlotVisitorrefused to read it in two places.attributes_forbailed unless the open tag was anHTMLOpenTagNode, so it found no attributes on a helper's element, andkey_parts_forknew aboutERBContentNodeandLiteralNodebut notRubyLiteralNode, which is what a keyword argument holds where a written attribute holds ERB.That parse is also what stops a helper taking a block from being marked as a block with markers inside it, which is a slot whose value is used, so
action_view_helpersis a required parser option here and not a recommended one.