Skip to content

Commit

Permalink
Merge pull request #11360 from rwjblue/add-warning-for-keyless-each
Browse files Browse the repository at this point in the history
[BUGFIX beta] Add a warning message when using keyless {{each}}.
  • Loading branch information
rwjblue committed Jun 6, 2015
2 parents 4d4f9e6 + 9f0c817 commit 73acd45
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/ember-htmlbars/lib/utils/decode-each-key.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import Ember from "ember-metal/core";
import { get } from "ember-metal/property_get";
import { guidFor } from "ember-metal/utils";

Expand All @@ -15,7 +16,12 @@ export default function decodeEachKey(item, keyPath, index) {
key = item;
break;
default:
key = keyPath ? get(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;
}
}

if (typeof key === 'number') {
Expand Down

0 comments on commit 73acd45

Please sign in to comment.