You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Doing a model.set('_page.greetingIds.0', 'foo'), I'd expect the binding to update, but it doesn't.
The binding does update properly under these other scenarios:
Setting the entire array: model.set('_page.greetingIds', ['foo'])
Changing the template to use the array index: {{ _page.greetings[@greetingIds[#i]] }}
Changing the template to not use an attribute: {{each _page.greetingIds as #id, #i}}
The text was updated successfully, but these errors were encountered:
ericyhwang
changed the title
Bug - {{each}} item binding with square brackets doesn't update when right side is an aliased attribute
[Bug] {{each}} item binding with square brackets doesn't update, when right side is an aliased attribute
Apr 29, 2020
Based on the fact that {{each _page.greetingIds}}does work, I've debugged it down to a difference between PathExpression#dependencies (works fine) and AttributePathExpression#dependencies (doesn't work).
In the screenshot, the left side is the working PathExpression, and the right side is the not-working AttributePathExpression.
Specifically, PathExpression's call to appendDependency results in a correct dep list, but AttributePathExpression's call to swapLastDependency does not.
As for a fix - Just to see what happens, since I suspected the early-return to be an issue, I tried changing the initial early-return check in swapLastDependency:
function swapLastDependency(dependencies, expression, context) {
- if (!expression.segments.length) {+ if (!expression.segments.length && !expression.meta) {
return dependencies;
}
That did fix the issue, and all the other tests pass... but I have no idea what the intent behind swapLastDependency is, nor do I know what that early-return is intended to do. My "see what happens" change is almost certainly not the correct fix.
The title is long and complicated. I have a repro of the issue using Derby's component tests:
ee2e1b0
Also putting the example here:
Doing a
model.set('_page.greetingIds.0', 'foo')
, I'd expect the binding to update, but it doesn't.The binding does update properly under these other scenarios:
model.set('_page.greetingIds', ['foo'])
{{ _page.greetings[@greetingIds[#i]] }}
{{each _page.greetingIds as #id, #i}}
The text was updated successfully, but these errors were encountered: