From 326dc3df8315aaa65ff5051cd30f1ebfcf9be43c Mon Sep 17 00:00:00 2001 From: bekzod Date: Sun, 9 Jul 2017 19:50:18 +0500 Subject: [PATCH] enable templates read a property from a function --- .../tests/integration/content-test.js | 16 ++++++++-------- packages/ember-metal/lib/property_set.js | 1 - packages/ember-metal/lib/tags.js | 2 +- packages/ember-metal/lib/watch_key.js | 7 +++---- 4 files changed, 12 insertions(+), 14 deletions(-) diff --git a/packages/ember-glimmer/tests/integration/content-test.js b/packages/ember-glimmer/tests/integration/content-test.js index cfd60ffa548..b68c84302b0 100644 --- a/packages/ember-glimmer/tests/integration/content-test.js +++ b/packages/ember-glimmer/tests/integration/content-test.js @@ -495,17 +495,17 @@ class DynamicContentTest extends RenderingTest { this.assertStableRerender(); - // this.runTask(() => set(func, 'aProp', 'still a property on a function')); - // this.assertContent('still a property on a function'); - // this.assertInvariants(); + 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'; + func = () => {}; + func.aProp = 'a prop on a new function'; - // this.runTask(() => set(this.context, 'func', func)); + this.runTask(() => set(this.context, 'func', func)); - // this.assertContent('a prop on a new function'); - // this.assertInvariants(); + this.assertContent('a prop on a new function'); + this.assertInvariants(); } } diff --git a/packages/ember-metal/lib/property_set.js b/packages/ember-metal/lib/property_set.js index e7adb0e89f2..9b284e293c5 100644 --- a/packages/ember-metal/lib/property_set.js +++ b/packages/ember-metal/lib/property_set.js @@ -67,7 +67,6 @@ export function set(obj, keyName, value, tolerant) { propertyDidChange(obj, keyName, meta); } - return value; } diff --git a/packages/ember-metal/lib/tags.js b/packages/ember-metal/lib/tags.js index 5e265cd9ad4..31d82c77bc3 100644 --- a/packages/ember-metal/lib/tags.js +++ b/packages/ember-metal/lib/tags.js @@ -13,7 +13,7 @@ function makeTag() { } export function tagForProperty(object, propertyKey, _meta) { - if (typeof object !== 'object' || object === null) { return CONSTANT_TAG; } + if ((typeof object !== 'object' && typeof object !== 'function') || object === null) { return CONSTANT_TAG; } let meta = _meta || metaFor(object); if (meta.isProxy()) { diff --git a/packages/ember-metal/lib/watch_key.js b/packages/ember-metal/lib/watch_key.js index da941d53852..be5362515bc 100644 --- a/packages/ember-metal/lib/watch_key.js +++ b/packages/ember-metal/lib/watch_key.js @@ -14,7 +14,7 @@ import { let handleMandatorySetter; export function watchKey(obj, keyName, meta) { - if (typeof obj !== 'object' || obj === null) { return; } + if (typeof obj !== 'object' && typeof obj !== 'function' || obj === null) { return; } let m = meta || metaFor(obj); let count = m.peekWatching(keyName) || 0; @@ -81,9 +81,8 @@ if (MANDATORY_SETTER) { } export function unwatchKey(obj, keyName, _meta) { - if (typeof obj !== 'object' || obj === null) { - return; - } + if (typeof obj !== 'object' && typeof obj !== 'function' || obj === null) { return; } + let meta = _meta || peekMeta(obj); // do nothing of this object has already been destroyed