-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
fix: Still failing bind:group for nested data #10379
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
nodes.push(node); | ||
} | ||
Identifier(node) { | ||
nodes.push(node); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will fail other parts of the code. And this would probably also yield a false-positive match for bind:group={group.a}
and bind:group={group[a]}
. We need to find a different way to compare these, possibly by exact string match. @tanhauhau how did this work exactly in Svelte 4?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just want to point out another possibly tricky case, in packages\svelte\tests\runtime-legacy\samples\binding-input-group-each-8\main.svelte
, where the group binding is using the key of a higher each loop, not the one it's in:
{#each keys as key (key)}
<h2>{key}</h2>
<ul>
{#each values as value (value)}
<li>
<label>
<input type="checkbox" name={key} {value} bind:group={object[key]} /> {value}
</label>
</li>
{/each}
</ul>
{/each}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My spontaneous thought is to use the bind:group expression itself as a key to the binding group object. What would be the problem with that?
Thanks again for the test, I hope #10410 fixed this for good |
Thank you for taking the time to figure this out. :) |
Before submitting the PR, please make sure you do the following
feat:
,fix:
,chore:
, ordocs:
.Description
After the #10368 fix in next.45, I tried my code to see if #9947 was fixed, but unfortunately it doesn't work for a simpler case. Apologies for providing an edge case test in
runtime-legacy/samples/binding-input-group-each-15
, but not a more common one.Currently,
extract_all_identifiers_from_expression
inast.js
won't extract both identifiers from$order.scoops
and$order.flavours
.Attempted fix
My attempt of fixing this (by no means a perfect fix) is to make
extract_all_identifiers_from_expression
return all identifiers, and in2-analyze/index.js
use the binding or the identifier when detecting what group to bind to.This fixes the test added in this PR,
runtime-legacy/samples/binding-input-group-each-16
but makes another test fail,runtime-legacy/samples/binding-input-group-each-12
. This makes me wonder if the combination of identifiers and each block to detect the group maybe isn't working properly.In the case of
each-16
, the$order.flavours
binding has no reference to its each block, which should make it "standalone", but still be fully referenced to distinguish it from$order.scoops
.On the other hand,
each-12
references its each block, which references its parent, and so on, so maybe it should be referenced all the way up topipelineOperations
, but that's the limit of my knowledge on how to reference it properly.