Skip to content

Commit

Permalink
[BUGFIX] args lost when passed to {{component}}
Browse files Browse the repository at this point in the history
Because iterator was not working as expected.
 `@` character was not applied to all of the @arg names in hash array,
 except for the first argument. It resulted in
 `[["@firstArg", "secondArg"], ["valOne", "valTwo"]]`, instead of
 `[["@firstArg", "@secondArg"], ["valOne", "valTwo"]]`

 Fixes emberjs/ember.js#19061
  • Loading branch information
rreckonerr committed Sep 21, 2020
1 parent 520fb6f commit b12e116
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,25 +50,37 @@ export class EmberishComponentTests extends RenderTest {

@test({ kind: 'glimmer' })
'Static block component helper'() {
this.registerComponent('Glimmer', 'A', 'A {{#component "B" arg1=@one}}{{/component}}');
this.registerComponent('Glimmer', 'B', 'B {{@arg1}}');
this.render('<A @one={{arg}} />', { arg: 1 });
this.assertHTML('A B 1');
this.registerComponent(
'Glimmer',
'A',
'A {{#component "B" arg1=@one arg2=@two arg3=@three}}{{/component}}'
);
this.registerComponent('Glimmer', 'B', 'B {{@arg1}} {{@arg2}} {{@arg3}}');
this.render('<A @one={{first}} @two={{second}} @three={{third}} />', {
first: 1,
second: 2,
third: 3,
});
this.assertHTML('A B 1 2 3');
this.assertStableRerender();
this.rerender({ arg: 2 });
this.assertHTML('A B 2');
this.rerender({ first: 2, second: 3, third: 4 });
this.assertHTML('A B 2 3 4');
this.assertStableNodes();
}

@test({ kind: 'glimmer' })
'Static inline component helper'() {
this.registerComponent('Glimmer', 'A', 'A {{component "B" arg1=@one}}');
this.registerComponent('Glimmer', 'B', 'B {{@arg1}}');
this.render('<A @one={{arg}} />', { arg: 1 });
this.assertHTML('A B 1');
this.registerComponent('Glimmer', 'A', 'A {{component "B" arg1=@one arg2=@two arg3=@three}}');
this.registerComponent('Glimmer', 'B', 'B {{@arg1}} {{@arg2}} {{@arg3}}');
this.render('<A @one={{first}} @two={{second}} @three={{third}} />', {
first: 1,
second: 2,
third: 3,
});
this.assertHTML('A B 1 2 3');
this.assertStableRerender();
this.rerender({ arg: 2 });
this.assertHTML('A B 2');
this.rerender({ first: 2, second: 3, third: 4 });
this.assertHTML('A B 2 3 4');
this.assertStableNodes();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ export function StaticComponentHelper(

if (compilable) {
if (hash) {
for (let i = 0; i < hash.length; i = i + 2) {
hash[i][0] = `@${hash[i][0]}`;
for (let i = 0; i < hash[0].length; i = i + 1) {
hash[0][i] = `@${hash[0][i]}`;
}
}

Expand Down

0 comments on commit b12e116

Please sign in to comment.