Skip to content

Commit

Permalink
[BUGFIX release] Setup named positionalParam array.
Browse files Browse the repository at this point in the history
Previously, when `positionalParams` was a string value (which means to
set all params as an array at that particular prop in `attrs`) we were
iterating over the length of the destination property name instead of
the available `params`.
  • Loading branch information
rwjblue committed Jul 31, 2015
1 parent fbe3f03 commit 4373ac6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,14 @@ function processPositionalParams(renderNode, positionalParams, params, attrs) {
attrs[positionalParams] = paramsStream;
}

for (let i = 0; i < positionalParams.length; i++) {
let param = params[paramsStartIndex + i];
if (isNamed) {
if (isNamed) {
for (let i = paramsStartIndex; i < params.length; i++) {
let param = params[i];
paramsStream.addDependency(param);
} else {
}
} else {
for (let i = 0; i < positionalParams.length; i++) {
let param = params[paramsStartIndex + i];
attrs[positionalParams[i]] = param;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -572,9 +572,9 @@ QUnit.test('static arbitrary number of positional parameters', function() {
QUnit.test('dynamic arbitrary number of positional parameters', function() {
var SampleComponent = Component.extend();
SampleComponent.reopenClass({
positionalParams: 'names'
positionalParams: 'n'
});
registry.register('template:components/sample-component', compile('{{#each attrs.names as |name|}}{{name}}{{/each}}'));
registry.register('template:components/sample-component', compile('{{#each attrs.n as |name|}}{{name}}{{/each}}'));
registry.register('component:sample-component', SampleComponent);

view = EmberView.extend({
Expand All @@ -597,6 +597,13 @@ QUnit.test('dynamic arbitrary number of positional parameters', function() {

equal(view.$('#direct').text(), 'Bar5');
equal(view.$('#helper').text(), 'Bar5');

run(function() {
set(view.context, 'user2', '6');
});

equal(view.$('#direct').text(), 'Bar6');
equal(view.$('#helper').text(), 'Bar6');
});

QUnit.test('moduleName is available on _renderNode when a layout is present', function() {
Expand Down

0 comments on commit 4373ac6

Please sign in to comment.