From 944e4a7362f8254d842c164bafb73b3d81e06540 Mon Sep 17 00:00:00 2001 From: Kris Selden Date: Tue, 1 Nov 2016 14:58:45 -0700 Subject: [PATCH] [BUGFIX beta] Fix non object paths --- packages/ember-metal/lib/chains.js | 2 +- packages/ember-metal/lib/watch_key.js | 6 ++++++ packages/ember-metal/lib/watch_path.js | 6 ++++++ packages/ember-metal/lib/watching.js | 3 +++ 4 files changed, 16 insertions(+), 1 deletion(-) diff --git a/packages/ember-metal/lib/chains.js b/packages/ember-metal/lib/chains.js index 3816d491021..1c3d6d603e3 100644 --- a/packages/ember-metal/lib/chains.js +++ b/packages/ember-metal/lib/chains.js @@ -166,7 +166,7 @@ function ChainNode(parent, key, value) { } function lazyGet(obj, key) { - if (!obj) { + if (!isObject(obj)) { return; } diff --git a/packages/ember-metal/lib/watch_key.js b/packages/ember-metal/lib/watch_key.js index c378bb29ea2..7bad0411f33 100644 --- a/packages/ember-metal/lib/watch_key.js +++ b/packages/ember-metal/lib/watch_key.js @@ -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 @@ -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 diff --git a/packages/ember-metal/lib/watch_path.js b/packages/ember-metal/lib/watch_path.js index 8d9176c9d75..5301b1614d1 100644 --- a/packages/ember-metal/lib/watch_path.js +++ b/packages/ember-metal/lib/watch_path.js @@ -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 @@ -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; diff --git a/packages/ember-metal/lib/watching.js b/packages/ember-metal/lib/watching.js index 5153a759c15..d05bdbb9713 100644 --- a/packages/ember-metal/lib/watching.js +++ b/packages/ember-metal/lib/watching.js @@ -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; }