From e915f2229c59f8b4c01f3df9535a2c8603278b45 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 +++---- packages/ember-metal/lib/watching.js | 2 +- yarn.lock | 21 ++----------------- 6 files changed, 15 insertions(+), 34 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 36304f07cd8..d0fc69f7692 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 diff --git a/packages/ember-metal/lib/watching.js b/packages/ember-metal/lib/watching.js index 2ea610b6f24..d18b69837a1 100644 --- a/packages/ember-metal/lib/watching.js +++ b/packages/ember-metal/lib/watching.js @@ -40,7 +40,7 @@ export function watch(obj, _keyPath, m) { } export function isWatching(obj, key) { - if (typeof obj !== 'object' || obj === null) { + if (typeof obj !== 'object' && typeof obj !== 'function' || obj === null) { return false; } let meta = peekMeta(obj); diff --git a/yarn.lock b/yarn.lock index f024e75f685..09949840c8f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -350,10 +350,6 @@ ast-types@0.8.12: version "0.8.12" resolved "https://registry.yarnpkg.com/ast-types/-/ast-types-0.8.12.tgz#a0d90e4351bb887716c83fd637ebf818af4adfcc" -ast-types@0.8.15: - version "0.8.15" - resolved "https://registry.yarnpkg.com/ast-types/-/ast-types-0.8.15.tgz#8eef0827f04dff0ec8857ba925abe3fea6194e52" - ast-types@0.9.11: version "0.9.11" resolved "https://registry.yarnpkg.com/ast-types/-/ast-types-0.9.11.tgz#371177bb59232ff5ceaa1d09ee5cad705b1a5aa9" @@ -3311,11 +3307,7 @@ homedir-polyfill@^1.0.0: dependencies: parse-passwd "^1.0.0" -hosted-git-info@^2.1.4, hosted-git-info@^2.1.5: - version "2.5.0" - resolved "https://registry.yarnpkg.com/hosted-git-info/-/hosted-git-info-2.5.0.tgz#6d60e34b3abbc8313062c3b798ef8d901a07af3c" - -hosted-git-info@~2.1.5: +hosted-git-info@^2.1.4, hosted-git-info@^2.1.5, hosted-git-info@~2.1.5: version "2.1.5" resolved "https://registry.yarnpkg.com/hosted-git-info/-/hosted-git-info-2.1.5.tgz#0ba81d90da2e25ab34a332e6ec77936e1598118b" @@ -5048,7 +5040,7 @@ realize-package-specifier@~3.0.3: dezalgo "^1.0.1" npm-package-arg "^4.1.1" -recast@0.10.33: +recast@0.10.33, recast@^0.10.10: version "0.10.33" resolved "https://registry.yarnpkg.com/recast/-/recast-0.10.33.tgz#942808f7aa016f1fa7142c461d7e5704aaa8d697" dependencies: @@ -5057,15 +5049,6 @@ recast@0.10.33: private "~0.1.5" source-map "~0.5.0" -recast@^0.10.10: - version "0.10.43" - resolved "https://registry.yarnpkg.com/recast/-/recast-0.10.43.tgz#b95d50f6d60761a5f6252e15d80678168491ce7f" - dependencies: - ast-types "0.8.15" - esprima-fb "~15001.1001.0-dev-harmony-fb" - private "~0.1.5" - source-map "~0.5.0" - recast@^0.11.17, recast@^0.11.3: version "0.11.23" resolved "https://registry.yarnpkg.com/recast/-/recast-0.11.23.tgz#451fd3004ab1e4df9b4e4b66376b2a21912462d3"