Skip to content

Commit

Permalink
Merge pull request #12628 from Serabe/fix-12613
Browse files Browse the repository at this point in the history
[BUGFIX beta] Fix processing arguments in rerender
  • Loading branch information
rwjblue committed Nov 19, 2015
2 parents 240b8c2 + ab72105 commit f03eab4
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 6 deletions.
13 changes: 7 additions & 6 deletions packages/ember-htmlbars/lib/hooks/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,6 @@ var IS_ANGLE_CACHE = new Cache(1000, function(key) {
export default function componentHook(renderNode, env, scope, _tagName, params, attrs, templates, visitor) {
var state = renderNode.getState();

// Determine if this is an initial render or a re-render
if (state.manager) {
state.manager.rerender(env, attrs, visitor);
return;
}

let tagName = _tagName;
if (CONTAINS_DOT_CACHE.get(tagName)) {
let stream = env.hooks.get(env, scope, tagName);
Expand All @@ -53,6 +47,13 @@ export default function componentHook(renderNode, env, scope, _tagName, params,
}
}

// Determine if this is an initial render or a re-render
if (state.manager) {
state.manager.rerender(env, attrs, visitor);
return;
}


let isAngleBracket = false;
let isTopLevel = false;
let isDasherized = false;
Expand Down
45 changes: 45 additions & 0 deletions packages/ember-htmlbars/tests/helpers/closure_component_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,51 @@ if (isEnabled('ember-contextual-components')) {
equal(component.$().text(), `${expectedText},Hola`, '-looked-up component rendered with rest params');
});

QUnit.test('renders with dot path and updates attributes', function() {
owner.register(
'component:my-nested-component',
Component.extend({
didReceiveAttrs() {
this.set('myProp', this.getAttr('my-parent-attr'));
}
})
);

owner.register(
'template:components/my-nested-component',
compile(`<span id='nested-prop'>{{myProp}}</span>`)
);

owner.register(
'template:components/my-component',
compile(`{{yield (hash my-nested-component=(component 'my-nested-component' my-parent-attr=attrs.my-attr))}}`)
);

let template = compile(`{{#my-component my-attr=myProp as |api|}}
{{api.my-nested-component}}
{{/my-component}}
<br>
<button onclick={{action 'changeValue'}}>Change value</button>`);
component = Component.extend({
[OWNER]: owner,
template,
myProp: 1,
actions: {
changeValue() { this.incrementProperty(`myProp`); }
}
}).create({ });

runAppend(component);

component.$('button').click();

equal(component.$('#nested-prop').text(), '2', 'value got updated');

component.$('button').click();

equal(component.$('#nested-prop').text(), '3', 'value got updated again');
});

QUnit.test('adding parameters to a closure component\'s instance does not add it to other instances', function(assert) {
owner.register(
'template:components/select-box',
Expand Down

0 comments on commit f03eab4

Please sign in to comment.