From c236d372daccf832109ccd3f6dea9a2e0913b787 Mon Sep 17 00:00:00 2001 From: Godhuda Date: Thu, 7 Apr 2016 15:56:24 -0700 Subject: [PATCH] Some misc fixes to get components working in apps --- package.json | 2 +- .../lib/system/application-instance.js | 2 ++ packages/ember-glimmer/lib/ember-metal-views/index.js | 5 ++++- .../ember-glimmer/lib/ember-routing-view/index.js | 5 ++++- packages/ember-glimmer/lib/ember-views/component.js | 4 ++++ packages/ember-glimmer/lib/utils/references.js | 1 + packages/ember/tests/component_registration_test.js | 11 +++-------- .../ember/tests/helpers/helper_registration_test.js | 7 +++++++ 8 files changed, 26 insertions(+), 11 deletions(-) diff --git a/package.json b/package.json index 8044f7e217c..e000219b733 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "express": "^4.5.0", "finalhandler": "^0.4.0", "github": "^0.2.3", - "glimmer-engine": "tildeio/glimmer#b184257", + "glimmer-engine": "tildeio/glimmer#2849de8", "glob": "^5.0.13", "htmlbars": "0.14.16", "mocha": "^2.4.5", diff --git a/packages/ember-application/lib/system/application-instance.js b/packages/ember-application/lib/system/application-instance.js index 594380da12f..d205269e1d8 100644 --- a/packages/ember-application/lib/system/application-instance.js +++ b/packages/ember-application/lib/system/application-instance.js @@ -141,8 +141,10 @@ const ApplicationInstance = EngineInstance.extend({ if (options.isInteractive) { registry.injection('view', 'renderer', 'renderer:-dom'); + registry.injection('component', 'renderer', 'renderer:-dom'); } else { registry.injection('view', 'renderer', 'renderer:-inert'); + registry.injection('component', 'renderer', 'renderer:-inert'); } if (options.rootElement) { diff --git a/packages/ember-glimmer/lib/ember-metal-views/index.js b/packages/ember-glimmer/lib/ember-metal-views/index.js index 2b7f04da9a3..cc770c80e74 100644 --- a/packages/ember-glimmer/lib/ember-metal-views/index.js +++ b/packages/ember-glimmer/lib/ember-metal-views/index.js @@ -15,12 +15,15 @@ class DynamicScope { class Renderer { constructor({ dom, env, destinedForDOM = false }) { + this._root = null; this._dom = dom; this._env = env; this._destinedForDOM = destinedForDOM; } appendOutletView(view, target) { + this._root = view; + let env = this._env; let self = new RootReference(view); let dynamicScope = new DynamicScope({ @@ -54,7 +57,7 @@ class Renderer { } rerender(view) { - view['_renderResult'].rerender(); + (view['_renderResult'] || this._root['_renderResult']).rerender(); } remove(view) { diff --git a/packages/ember-glimmer/lib/ember-routing-view/index.js b/packages/ember-glimmer/lib/ember-routing-view/index.js index f1f59ac7852..5d6dd9c5604 100644 --- a/packages/ember-glimmer/lib/ember-routing-view/index.js +++ b/packages/ember-glimmer/lib/ember-routing-view/index.js @@ -85,7 +85,10 @@ export class OutletView { } } - appendChild() { } + appendChild(instance) { + instance.parentView = this; + instance.ownerView = this; + } rerender() { if (this._renderResult) { this.renderer.rerender(this); } diff --git a/packages/ember-glimmer/lib/ember-views/component.js b/packages/ember-glimmer/lib/ember-views/component.js index 4af2dbabdb8..12e78f068d1 100644 --- a/packages/ember-glimmer/lib/ember-views/component.js +++ b/packages/ember-glimmer/lib/ember-views/component.js @@ -22,5 +22,9 @@ export default CoreView.extend( init() { this._super(...arguments); this._viewRegistry = this._viewRegistry || EmberView.views; + }, + + __defineNonEnumerable(property) { + this[property.name] = property.descriptor.value; } }); diff --git a/packages/ember-glimmer/lib/utils/references.js b/packages/ember-glimmer/lib/utils/references.js index 3ec6dfafebb..e83e8d60dbf 100644 --- a/packages/ember-glimmer/lib/utils/references.js +++ b/packages/ember-glimmer/lib/utils/references.js @@ -106,6 +106,7 @@ export class UpdatableReference extends EmberPathReference { // @implements PathReference export class GetHelperReference extends CachedReference { constructor(sourceReference, pathReference) { + super(); this.sourceReference = sourceReference; this.pathReference = pathReference; this.tag = combineTagged([sourceReference, pathReference]); diff --git a/packages/ember/tests/component_registration_test.js b/packages/ember/tests/component_registration_test.js index b7525c7b3e9..ef8033c5500 100644 --- a/packages/ember/tests/component_registration_test.js +++ b/packages/ember/tests/component_registration_test.js @@ -98,6 +98,9 @@ QUnit.test('If a component is registered, it is used', function() { } +if (!isEnabled('ember-glimmer')) { + // jscs:disable + QUnit.test('Late-registered components can be rendered with custom `layout` property', function() { Ember.TEMPLATES.application = compile('
there goes {{my-hero}}
'); @@ -112,9 +115,6 @@ QUnit.test('Late-registered components can be rendered with custom `layout` prop ok(!helpers['my-hero'], 'Component wasn\'t saved to global helpers hash'); }); -if (!isEnabled('ember-glimmer')) { - // jscs:disable - QUnit.test('Late-registered components can be rendered with template registered on the container', function() { Ember.TEMPLATES.application = compile('
hello world {{sally-rutherford}}-{{#sally-rutherford}}!!!{{/sally-rutherford}}
'); @@ -247,8 +247,6 @@ QUnit.test('Using name of component that does not exist', function () { }, /A helper named 'no-good' could not be found/); }); -} - QUnit.module('Application Lifecycle - Component Context', { setup: prepare, teardown: cleanup @@ -304,9 +302,6 @@ QUnit.test('Components without a block should have the proper content when a tem equal(jQuery('#wrapper').text(), 'inner', 'The component is composed correctly'); }); -if (!isEnabled('ember-glimmer')) { - // jscs:disable - QUnit.test('Components without a block should have the proper content', function() { Ember.TEMPLATES.application = compile('
{{my-component}}
'); diff --git a/packages/ember/tests/helpers/helper_registration_test.js b/packages/ember/tests/helpers/helper_registration_test.js index 9233c40fab0..ca6b131791d 100644 --- a/packages/ember/tests/helpers/helper_registration_test.js +++ b/packages/ember/tests/helpers/helper_registration_test.js @@ -7,6 +7,7 @@ import Helper, { helper } from 'ember-htmlbars/helper'; import Application from 'ember-application/system/application'; import jQuery from 'ember-views/system/jquery'; import inject from 'ember-runtime/inject'; +import isEnabled from 'ember-metal/features'; import { registerKeyword, resetKeyword } from 'ember-htmlbars/tests/utils'; import viewKeyword from 'ember-htmlbars/keywords/view'; @@ -104,6 +105,10 @@ QUnit.test('Undashed helpers registered on the container can be invoked', functi equal(jQuery('#wrapper').text(), 'OMG|boo|ya', 'The helper was invoked from the container'); }); +if (!isEnabled('ember-glimmer')) { +// jscs:disable + +// needs glimmer Helper QUnit.test('Helpers can receive injections', function() { Ember.TEMPLATES.application = compile('
{{full-name}}
'); @@ -124,3 +129,5 @@ QUnit.test('Helpers can receive injections', function() { ok(serviceCalled, 'service was injected, method called'); }); + +}