Skip to content

Commit

Permalink
enable templates read a property from a function
Browse files Browse the repository at this point in the history
  • Loading branch information
bekzod committed Jul 9, 2017
1 parent 054b149 commit 8489fc6
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 13 deletions.
6 changes: 3 additions & 3 deletions packages/ember-glimmer/lib/utils/references.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
1 change: 0 additions & 1 deletion packages/ember-metal/lib/property_set.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ export function set(obj, keyName, value, tolerant) {

propertyDidChange(obj, keyName, meta);
}

return value;
}

Expand Down
4 changes: 2 additions & 2 deletions packages/ember-metal/lib/tags.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand All @@ -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 {
Expand Down
7 changes: 3 additions & 4 deletions packages/ember-metal/lib/watch_key.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions packages/ember-metal/lib/watch_path.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion packages/ember-metal/lib/watching.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 8489fc6

Please sign in to comment.