-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[BUGFIX release] Allows @each to work with arrays that contain falsy …
…values This matches the original behavior as seen in the each_proxy.
- Loading branch information
Chris Garrett
committed
Oct 9, 2019
1 parent
f786e42
commit 8698e09
Showing
2 changed files
with
29 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -457,6 +457,28 @@ moduleFor( | |
assert.deepEqual(n.normalized, []); | ||
} | ||
|
||
['@test @each works on array with falsy values'](assert) { | ||
let obj = EmberObject.extend({ | ||
falsy: [null, undefined, false, '', 0, {}], | ||
truthy: [true, 'foo', 123], | ||
|
||
falsyComputed: computed('[email protected]', () => { | ||
assert.ok(true, 'falsy computed'); | ||
}), | ||
|
||
truthyComputed: computed('[email protected]', () => { | ||
assert.ok(true, 'truthy computed'); | ||
}), | ||
}).create(); | ||
|
||
// should throw no errors | ||
obj.falsyComputed; | ||
|
||
assert.throws(() => { | ||
obj.truthyComputed; | ||
}, /When using @each to observe the array `true,foo,123`, the items in the array must be objects/); | ||
} | ||
|
||
['@test @each works with array-likes'](assert) { | ||
class ArrayLike { | ||
constructor(arr = []) { | ||
|