Skip to content

Commit

Permalink
[BUGFIX beta] Fix non object paths
Browse files Browse the repository at this point in the history
  • Loading branch information
krisselden committed Nov 1, 2016
1 parent f359046 commit 944e4a7
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/ember-metal/lib/chains.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ function ChainNode(parent, key, value) {
}

function lazyGet(obj, key) {
if (!obj) {
if (!isObject(obj)) {
return;
}

Expand Down
6 changes: 6 additions & 0 deletions packages/ember-metal/lib/watch_key.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ import {
let handleMandatorySetter;

export function watchKey(obj, keyName, meta) {
if (typeof obj !== 'object' || obj === null) {
return;
}
let m = meta || metaFor(obj);

// activate watching first time
Expand Down Expand Up @@ -86,6 +89,9 @@ if (isEnabled('mandatory-setter')) {
import { UNDEFINED } from './meta';

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

// do nothing of this object has already been destroyed
Expand Down
6 changes: 6 additions & 0 deletions packages/ember-metal/lib/watch_path.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ export function makeChainNode(obj) {
}

export function watchPath(obj, keyPath, meta) {
if (typeof obj !== 'object' || obj === null) {
return;
}
let m = meta || metaFor(obj);
let counter = m.peekWatching(keyPath) || 0;
if (!counter) { // activate watching first time
Expand All @@ -26,6 +29,9 @@ export function watchPath(obj, keyPath, meta) {
}

export function unwatchPath(obj, keyPath, meta) {
if (typeof obj !== 'object' || obj === null) {
return;
}
let m = meta || metaFor(obj);
let counter = m.peekWatching(keyPath) || 0;

Expand Down
3 changes: 3 additions & 0 deletions packages/ember-metal/lib/watching.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ function watch(obj, _keyPath, m) {
export { watch };

export function isWatching(obj, key) {
if (typeof obj !== 'object' || obj === null) {
return false;
}
let meta = peekMeta(obj);
return (meta && meta.peekWatching(key)) > 0;
}
Expand Down

0 comments on commit 944e4a7

Please sign in to comment.