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
TypeError: null is not an object (evaluating 'seek.key')
The obvious use case that comes to mind is a spread sheet type app where you have columns of number arrays and you want to use an each helper in your template to render the data.
The obvious workaround is to select a different key type such as key="@index"
{{#each numbers key="@index" as | item |}}
{{item}}<br>
{{/each}}
{{#each letters key="@index" as | item |}}
{{item}}<br>
{{/each}}
But given that key="@identity" is the default behavior (I believe), the nuance of this behavior might be lost on some users.
And more serious is if a dupe primitive value shows up somewhere deep in your array you will have problems
numbers: [1,2,3,1]
Which is a much more likely scenario.
I think this is a known issue, just posting in case others stumble across this not so obvious bug and looking for an explanation.
I will see about creating a failing test case just as soon as I can figure out how to write it up.
In ember the @identity helper is implemented like this:
function identity(item) {
let key;
let type = typeof item;
if (type === 'string' || type === 'number') {
key = item;
} else {
key = guidFor(item);
}
return key;
}
Was chatting with @krisselden on slack about this.
If you have an array with dupe primitive values such as this
The each helper will not render them.
It is only when you dedupe the arrays that it works.
Here is a failing JSBin
http://emberjs.jsbin.com/tozule/3/edit?html,js
You get a null reference and the following error
The obvious use case that comes to mind is a spread sheet type app where you have columns of number arrays and you want to use an each helper in your template to render the data.
The obvious workaround is to select a different key type such as
key="@index"
But given that
key="@identity"
is the default behavior (I believe), the nuance of this behavior might be lost on some users.And more serious is if a dupe primitive value shows up somewhere deep in your array you will have problems
Which is a much more likely scenario.
I think this is a known issue, just posting in case others stumble across this not so obvious bug and looking for an explanation.
I will see about creating a failing test case just as soon as I can figure out how to write it up.
In ember the @identity helper is implemented like this:
https://github.com/emberjs/ember.js/blob/master/packages/ember-htmlbars/lib/utils/decode-each-key.js
The text was updated successfully, but these errors were encountered: