-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
[BUGFIX release] Default {{each}} key to @guid or @item based on type. #11461
Conversation
@@ -19,8 +19,13 @@ export default function decodeEachKey(item, keyPath, index) { | |||
if (keyPath) { | |||
key = get(item, keyPath); | |||
} else { | |||
Ember.warn('Using `{{each}}` without specifying a key can lead to unusual behavior. Please specify a `key` that identifies a unique value on each item being iterated. E.g. `{{each model key="@guid" as |item|}}`.'); | |||
key = index; | |||
let type = typeOf(item); |
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.
Why not just typeof
?
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.
yes, lets just use JS typeof here
Looks good 👍 |
yay 👍 |
Update:
|
I am +1. I've also heard many WAT about the current behavior |
df1d4bb
to
d2094bb
Compare
Updated (hopefully for the last time) to deprecate |
FYI: It seems that this commit didn't get into the 1.13.1 tag |
Thanks!! ⛵ |
This PR uses
@item
as the key when the item being iterated is a string or number, and uses@guid
when it is anything else.This is an attempt at making a better default, to prevent users from having to specify a
key=
to each{{each}}
invocation.It is absolutely possible, that we will want to revisit this and make specifying
key
required in the future, but it seems that we should attempt at good defaults before making that decision.