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 14, 2017
1 parent 2adb0fd commit 8975738
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 12 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 @@ -217,7 +217,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 @@ -315,7 +315,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);
Expand Down Expand Up @@ -396,7 +396,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);
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 @@ -67,7 +67,6 @@ export function set(obj, keyName, value, tolerant) {

propertyDidChange(obj, keyName, meta);
}

return value;
}

Expand Down
2 changes: 1 addition & 1 deletion 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 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 @@ -10,7 +10,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 @@ -21,7 +21,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 @@ -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);
Expand Down

0 comments on commit 8975738

Please sign in to comment.