Skip to content

Commit e24017e

Browse files
authored
use confirmedArrays when performing intersect (#384)
1 parent 5754b41 commit e24017e

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

addon/helpers/intersect.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ export function intersect([...arrays]) {
77
});
88
// copied from https://github.com/emberjs/ember.js/blob/315ec6472ff542ac714432036cc96fe4bd62bd1f/packages/%40ember/object/lib/computed/reduce_computed_macros.js#L1063-L1100
99
let results = confirmedArrays.pop().filter(candidate => {
10-
for (let i = 0; i < arrays.length; i++) {
10+
for (let i = 0; i < confirmedArrays.length; i++) {
1111
let found = false;
12-
let array = arrays[i];
12+
let array = confirmedArrays[i];
1313
for (let j = 0; j < array.length; j++) {
1414
if (array[j] === candidate) {
1515
found = true;

tests/integration/helpers/intersect-test.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,18 @@ module('Integration | Helper | {{intersect}}', function(hooks) {
5151

5252
assert.equal(find('*').textContent.trim(), 'this is all that will render', 'no error is thrown');
5353
});
54+
55+
test('it allows a first parameter null array', async function(assert) {
56+
this.set('array1', null);
57+
this.set('array2', ['foo', 'baz']);
58+
59+
await render(hbs`
60+
this is all that will render
61+
{{#each (intersect array1 array2) as |value|}}
62+
{{value}}
63+
{{/each}}
64+
`);
65+
66+
assert.equal(find('*').textContent.trim(), 'this is all that will render', 'no error is thrown');
67+
});
5468
});

0 commit comments

Comments
 (0)