Skip to content

Commit

Permalink
Merge pull request #15325 from rwjblue/update-mount-engine-params
Browse files Browse the repository at this point in the history
[FEATURE ember-engines-mount-params] Constrain to `model` hash arg.
  • Loading branch information
rwjblue authored Jun 4, 2017
2 parents b2c628b + e66261d commit d338c60
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
16 changes: 8 additions & 8 deletions packages/ember-glimmer/lib/component-managers/mount.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class MountManager extends AbstractManager {
let bucket = { engine };

if (EMBER_ENGINES_MOUNT_PARAMS) {
bucket.args = args.capture();
bucket.modelReference = args.named.get('model');
}

return bucket;
Expand All @@ -41,15 +41,15 @@ class MountManager extends AbstractManager {
}

getSelf(bucket) {
let { engine, args } = bucket;
let { engine, modelReference } = bucket;

let applicationFactory = engine.factoryFor(`controller:application`);
let controllerFactory = applicationFactory || generateControllerFactory(engine, 'application');
let controller = bucket.controller = controllerFactory.create();

if (EMBER_ENGINES_MOUNT_PARAMS) {
let model = args.named.value();
bucket.argsRevision = args.tag.value();
let model = modelReference.value();
bucket.modelRevision = modelReference.tag.value();
controller.set('model', model);
}

Expand All @@ -68,11 +68,11 @@ class MountManager extends AbstractManager {

update(bucket) {
if (EMBER_ENGINES_MOUNT_PARAMS) {
let { controller, args, argsRevision } = bucket;
let { controller, modelReference, modelRevision } = bucket;

if (!args.tag.validate(argsRevision)) {
let model = args.named.value();
bucket.argsRevision = args.tag.value();
if (!modelReference.tag.validate(modelRevision)) {
let model = modelReference.value();
bucket.modelRevision = modelReference.tag.value();
controller.set('model', model);
}
}
Expand Down
6 changes: 3 additions & 3 deletions packages/ember-glimmer/tests/integration/mount-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ if (EMBER_ENGINES_MOUNT_PARAMS) {
this.router.map(function() {
this.route('engine-params-static');
});
this.addTemplate('engine-params-static', '{{mount "paramEngine" foo="bar"}}');
this.addTemplate('engine-params-static', '{{mount "paramEngine" model=(hash foo="bar")}}');

return this.visit('/engine-params-static').then(() => {
this.assertComponentElement(this.firstChild, { content: '<h2>Param Engine: bar</h2>' });
Expand All @@ -227,7 +227,7 @@ if (EMBER_ENGINES_MOUNT_PARAMS) {
controller = this;
}
}));
this.addTemplate('engine-params-bound', '{{mount "paramEngine" foo=boundParamValue}}');
this.addTemplate('engine-params-bound', '{{mount "paramEngine" model=(hash foo=boundParamValue)}}');

return this.visit('/engine-params-bound').then(() => {
this.assertComponentElement(this.firstChild, { content: '<h2>Param Engine: </h2>' });
Expand Down Expand Up @@ -277,7 +277,7 @@ if (EMBER_ENGINES_MOUNT_PARAMS) {
this.register('template:application', compile('{{model.foo}}', { moduleName: 'application' }));
}
}));
this.addTemplate('engine-params-contextual-component', '{{mount "componentParamEngine" foo=(component "foo-component")}}');
this.addTemplate('engine-params-contextual-component', '{{mount "componentParamEngine" model=(hash foo=(component "foo-component"))}}');

return this.visit('/engine-params-contextual-component').then(() => {
this.assertComponentElement(this.firstChild.firstChild, { content: 'foo-component rendered! - rendered app-bar-component from the app' });
Expand Down

0 comments on commit d338c60

Please sign in to comment.