Skip to content

Commit

Permalink
[BUGFIX beta] Create a new hash parameter when creating a component cell
Browse files Browse the repository at this point in the history
If we merge positional and hash parameters without duplicating the hash before,
then we get an error when rerendering.

Fixes test in #12711

(cherry picked from commit 4e7fe48)
  • Loading branch information
Serabe authored and rwjblue committed Dec 27, 2015
1 parent 562d486 commit 87a5915
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
7 changes: 5 additions & 2 deletions packages/ember-htmlbars/lib/hooks/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { assert } from 'ember-metal/debug';
import ComponentNodeManager from 'ember-htmlbars/node-managers/component-node-manager';
import buildComponentTemplate, { buildHTMLTemplate } from 'ember-views/system/build-component-template';
import lookupComponent from 'ember-htmlbars/utils/lookup-component';
import assign from 'ember-metal/assign';
import EmptyObject from 'ember-metal/empty_object';
import Cache from 'ember-metal/cache';
import {
CONTAINS_DASH_CACHE,
Expand Down Expand Up @@ -41,9 +43,10 @@ export default function componentHook(renderNode, env, scope, _tagName, params,
* on top of the closure component attributes.
*
*/
processPositionalParamsFromCell(componentCell, params, attrs);
let newAttrs = assign(new EmptyObject(), attrs);
processPositionalParamsFromCell(componentCell, params, newAttrs);
params = [];
attrs = mergeInNewHash(componentCell[COMPONENT_HASH], attrs);
attrs = mergeInNewHash(componentCell[COMPONENT_HASH], newAttrs);
}
}

Expand Down
7 changes: 5 additions & 2 deletions packages/ember-htmlbars/lib/keywords/closure-component.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { assert } from 'ember-metal/debug';
import isNone from 'ember-metal/is_none';
import symbol from 'ember-metal/symbol';
import BasicStream from 'ember-metal/streams/stream';
import EmptyObject from 'ember-metal/empty_object';
import { read } from 'ember-metal/streams/utils';
import { labelForSubexpr } from 'ember-htmlbars/hooks/subexpr';
import assign from 'ember-metal/assign';
Expand Down Expand Up @@ -54,12 +55,14 @@ function createClosureComponentCell(env, originalComponentPath, params, hash, la
assert(`Component path cannot be null in ${label}`,
!isNone(componentPath));

let newHash = assign(new EmptyObject(), hash);

if (isComponentCell(componentPath)) {
return createNestedClosureComponentCell(componentPath, params, hash);
return createNestedClosureComponentCell(componentPath, params, newHash);
} else {
assert(`The component helper cannot be used without a valid component name. You used "${componentPath}" via ${label}`,
isValidComponentPath(env, componentPath));
return createNewClosureComponentCell(env, componentPath, params, hash);
return createNewClosureComponentCell(env, componentPath, params, newHash);
}
}

Expand Down

0 comments on commit 87a5915

Please sign in to comment.