diff --git a/packages/ember-glimmer/lib/utils/references.js b/packages/ember-glimmer/lib/utils/references.js index fda919586ab..e360b08385a 100644 --- a/packages/ember-glimmer/lib/utils/references.js +++ b/packages/ember-glimmer/lib/utils/references.js @@ -213,11 +213,13 @@ export class NestedPropertyReference extends PropertyReference { _parentObjectTag.update(tagForProperty(parentValue, _propertyKey)); - if (typeof parentValue === 'string' && _propertyKey === 'length') { + let parentValueType = typeof parentValue; + + if (parentValueType === 'string' && _propertyKey === 'length') { return parentValue.length; } - if (typeof parentValue === 'object' && parentValue) { + if (parentValueType === 'object' && parentValue !== null || parentValueType === 'function') { if (MANDATORY_SETTER) { watchKey(parentValue, _propertyKey); } @@ -315,7 +317,7 @@ export class SimpleHelperReference extends CachedReference { let result = helper(positionalValue, namedValue); - if (typeof result === 'object' && result !== null) { + if (typeof result === 'object' && result !== null || typeof result === 'function') { return new RootReference(result); } else { return PrimitiveReference.create(result); @@ -396,7 +398,7 @@ export class InternalHelperReference extends CachedReference { // @implements PathReference export class UnboundReference extends ConstReference { static create(value) { - if (typeof value === 'object' && value !== null) { + if (typeof value === 'object' && value !== null || typeof result === 'function') { return new UnboundReference(value); } else { return PrimitiveReference.create(value); diff --git a/packages/ember-glimmer/tests/integration/content-test.js b/packages/ember-glimmer/tests/integration/content-test.js index 542a05e12a2..cfd60ffa548 100644 --- a/packages/ember-glimmer/tests/integration/content-test.js +++ b/packages/ember-glimmer/tests/integration/content-test.js @@ -484,6 +484,29 @@ class DynamicContentTest extends RenderingTest { this.assertContent('hello'); this.assertInvariants(); } + + ['@test it can render a property on a function']() { + let func = () => {}; + func.aProp = 'this is a property on a function'; + + this.renderPath('func.aProp', { func }); + + this.assertContent('this is a property on a function'); + + this.assertStableRerender(); + + // this.runTask(() => set(func, 'aProp', 'still a property on a function')); + // this.assertContent('still a property on a function'); + // this.assertInvariants(); + + // func = () => {}; + // func.aProp = 'a prop on a new function'; + + // this.runTask(() => set(this.context, 'func', func)); + + // this.assertContent('a prop on a new function'); + // this.assertInvariants(); + } } const EMPTY = {};