Skip to content

Commit

Permalink
failing test for reading a property off of a function
Browse files Browse the repository at this point in the history
  • Loading branch information
Kyle Turney authored and bekzod committed Jul 19, 2017
1 parent af58855 commit 49fb515
Show file tree
Hide file tree
Showing 5 changed files with 153 additions and 46 deletions.
24 changes: 24 additions & 0 deletions packages/ember-glimmer/tests/integration/content-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,30 @@ class DynamicContentTest extends RenderingTest {
this.assertContent('hello');
this.assertInvariants();
}

['@test it can render a property on a function']() {
let func = () => {};
func.aProp = 'this is a property on a function';

this.renderPath('func.aProp', { func });

this.assertContent('this is a property on a function');

this.assertStableRerender();

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';

this.runTask(() => set(this.context, 'func', func));

this.assertContent('a prop on a new function');
this.assertInvariants();
}
}

const EMPTY = {};
Expand Down
4 changes: 2 additions & 2 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' && typeof obj !== 'function' || obj === null) { return; }
if (typeof obj !== 'object' || obj === null) { return; }

let m = meta || metaFor(obj);
let count = m.peekWatching(keyName) || 0;
Expand Down Expand Up @@ -81,7 +81,7 @@ if (MANDATORY_SETTER) {
}

export function unwatchKey(obj, keyName, _meta) {
if (typeof obj !== 'object' && typeof obj !== 'function' || obj === null) { return; }
if (typeof obj !== 'object' || obj === null) { return; }

let meta = _meta || peekMeta(obj);

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' && typeof obj !== 'function' || obj === null) { return; }
if (typeof obj !== 'object' || 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' && typeof obj !== 'function' || obj === null) { return; }
if (typeof obj !== 'object' || 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' && typeof obj !== 'function' || obj === null) {
if (typeof obj !== 'object' || obj === null) {
return false;
}
let meta = peekMeta(obj);
Expand Down
Loading

0 comments on commit 49fb515

Please sign in to comment.