diff --git a/packages/ember-glimmer/lib/utils/references.js b/packages/ember-glimmer/lib/utils/references.js index 75ac4b368e0..762b6eddea5 100644 --- a/packages/ember-glimmer/lib/utils/references.js +++ b/packages/ember-glimmer/lib/utils/references.js @@ -220,7 +220,7 @@ export class NestedPropertyReference extends PropertyReference { return parentValue.length; } - if (typeof parentValue === 'object' && parentValue) { + if ((typeof parentValue === 'object' || typeof parentValue === 'function') && parentValue) { if (MANDATORY_SETTER) { watchKey(parentValue, _propertyKey); } @@ -322,7 +322,7 @@ export class SimpleHelperReference extends CachedReference { return NULL_REFERENCE; } else if (result === undefined) { return UNDEFINED_REFERENCE; - } else if (typeof result === 'object') { + } else if (typeof result === 'object' || typeof result === 'function') { return new RootReference(result); } else { return PrimitiveReference.create(result); @@ -407,7 +407,7 @@ export class UnboundReference extends ConstReference { return NULL_REFERENCE; } else if (value === undefined) { return UNDEFINED_REFERENCE; - } else if (typeof value === 'object') { + } else if (typeof value === 'object' || typeof result === 'function') { return new UnboundReference(value); } else { return PrimitiveReference.create(value); diff --git a/packages/ember-metal/lib/property_set.js b/packages/ember-metal/lib/property_set.js index bb316c643b8..47be6434d3a 100644 --- a/packages/ember-metal/lib/property_set.js +++ b/packages/ember-metal/lib/property_set.js @@ -68,7 +68,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 b5dbd55c52e..ebd4076e586 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()) { @@ -28,7 +28,7 @@ export function tagForProperty(object, propertyKey, _meta) { } export function tagFor(object, _meta) { - if (typeof object === 'object' && object !== null) { + if (typeof object === 'object' && object !== null || typeof object === 'function') { let meta = _meta || metaFor(object); return meta.writableTag(makeTag); } else { 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/watch_path.js b/packages/ember-metal/lib/watch_path.js index fb76aaa84f1..1fbb6cbc1a8 100644 --- a/packages/ember-metal/lib/watch_path.js +++ b/packages/ember-metal/lib/watch_path.js @@ -16,7 +16,7 @@ export function makeChainNode(obj) { } export function watchPath(obj, keyPath, meta) { - if (typeof obj !== 'object' || obj === null) { return; } + if (typeof obj !== 'object' && typeof obj !== 'function' || obj === null) { return; } let m = meta || metaFor(obj); let counter = m.peekWatching(keyPath) || 0; @@ -27,7 +27,7 @@ export function watchPath(obj, keyPath, meta) { } export function unwatchPath(obj, keyPath, meta) { - if (typeof obj !== 'object' || obj === null) { return; } + if (typeof obj !== 'object' && typeof obj !== 'function' || obj === null) { return; } let m = meta || peekMeta(obj); if (m === undefined) { return; } let counter = m.peekWatching(keyPath) || 0; diff --git a/packages/ember-metal/lib/watching.js b/packages/ember-metal/lib/watching.js index d05bdbb9713..0bf5c5028d0 100644 --- a/packages/ember-metal/lib/watching.js +++ b/packages/ember-metal/lib/watching.js @@ -42,7 +42,7 @@ function watch(obj, _keyPath, m) { export { watch }; 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);