Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP][BUGFIX Beta] Positional param clash on rerender of contextual component helper #12711

Merged
merged 1 commit into from Dec 21, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { assert } from 'ember-metal/debug';
import { Stream } from 'ember-metal/streams/stream';
import { readArray } from 'ember-metal/streams/utils';
import { isStream, readArray } from 'ember-metal/streams/utils';

export default function extractPositionalParams(renderNode, component, params, attrs) {
let positionalParams = component.positionalParams;
Expand All @@ -25,9 +25,10 @@ function processNamedPositionalParameters(renderNode, positionalParams, params,

for (let i = 0; i < limit; i++) {
let param = params[i];
let isActiveStreamParam = isStream(param) && param.isActive;

assert(`You cannot specify both a positional param (at position ${i}) and the hash argument \`${positionalParams[i]}\`.`,
!(positionalParams[i] in attrs));
isActiveStreamParam || !(positionalParams[i] in attrs));

attrs[positionalParams[i]] = param;
}
Expand Down
32 changes: 32 additions & 0 deletions packages/ember-htmlbars/tests/helpers/closure_component_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,38 @@ if (isEnabled('ember-contextual-components')) {
}, `You cannot specify both a positional param (at position 0) and the hash argument \`name\`.`);
});

QUnit.test('conflicting positional and hash parameters does not raise and assertion if rerendered', function() {
let LookedUp = Component.extend();
LookedUp.reopenClass({
positionalParams: ['name']
});
owner.register(
'component:-looked-up',
LookedUp
);
owner.register(
'template:components/-looked-up',
compile(`{{greeting}} {{name}}`)
);

let template = compile(
`{{component (component "-looked-up" name greeting="Hodi")}}`
);

component = Component.extend({
[OWNER]: owner,
template,
name: 'Hodari'
}).create();

runAppend(component);
equal(component.$().text(), 'Hodi Hodari', 'component is rendered');

run(() => component.set('name', 'Sergio'));

equal(component.$().text(), 'Hodi Sergio', 'component is rendered');
});

QUnit.test('conflicting positional and hash parameters does not raise and assertion if in the different closure', function() {
let LookedUp = Component.extend();
LookedUp.reopenClass({
Expand Down