Skip to content

Commit

Permalink
Merge pull request #15107 from emberjs/to-boolean-chains
Browse files Browse the repository at this point in the history
[BUGFIX beta] avoid toBoolean conversion when possible (chains)
  • Loading branch information
stefanpenner authored Apr 4, 2017
2 parents 6fe9719 + 72cad69 commit 2c45a3b
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions packages/ember-metal/lib/chains.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,18 +145,18 @@ class ChainNode {
// It is false for the root of a chain (because we have no parent)
// and for global paths (because the parent node is the object with
// the observer on it)
this._watching = (value === undefined);
let isWatching = this._watching = (value === undefined);

this._chains = undefined;
this._object = undefined;
this.count = 0;

this._value = value;
this._paths = undefined;
if (this._watching) {
if (isWatching === true) {
let obj = parent.value();

if (!isObject(obj)) {
if (!isObject(obj) === true) {
return;
}

Expand All @@ -167,15 +167,15 @@ class ChainNode {
}

value() {
if (this._value === undefined && this._watching) {
if (this._value === undefined && this._watching === true) {
let obj = this._parent.value();
this._value = lazyGet(obj, this._key);
}
return this._value;
}

destroy() {
if (this._watching) {
if (this._watching === true) {
let obj = this._object;
if (obj) {
removeChainWatcher(obj, this._key, this);
Expand Down Expand Up @@ -271,11 +271,11 @@ class ChainNode {
}

notify(revalidate, affected) {
if (revalidate && this._watching) {
if (revalidate && this._watching === true) {
let parentValue = this._parent.value();

if (parentValue !== this._object) {
if (this._object) {
if (this._object !== undefined) {
removeChainWatcher(this._object, this._key, this);
}

Expand All @@ -292,7 +292,7 @@ class ChainNode {
// then notify chains...
let chains = this._chains;
let node;
if (chains) {
if (chains !== undefined) {
for (let key in chains) {
node = chains[key];
if (node !== undefined) {
Expand Down Expand Up @@ -329,12 +329,12 @@ function lazyGet(obj, key) {
let meta = peekMeta(obj);

// check if object meant only to be a prototype
if (meta && meta.proto === obj) {
if (meta !== undefined && meta.proto === obj) {
return;
}

// Use `get` if the return value is an EachProxy or an uncacheable value.
if (isVolatile(obj[key])) {
if (isVolatile(obj[key]) === true) {
return get(obj, key);
// Otherwise attempt to get the cached value of the computed property
} else {
Expand All @@ -350,17 +350,17 @@ import { makeChainNode } from './watch_path';
export function finishChains(obj) {
// We only create meta if we really have to
let m = peekMeta(obj);
if (m) {
if (m !== undefined) {
m = metaFor(obj);

// finish any current chains node watchers that reference obj
let chainWatchers = m.readableChainWatchers();
if (chainWatchers) {
if (chainWatchers !== undefined) {
chainWatchers.revalidateAll();
}
// ensure that if we have inherited any chains they have been
// copied onto our own meta.
if (m.readableChains()) {
if (m.readableChains() !== undefined) {
m.writableChains(makeChainNode);
}
}
Expand Down

0 comments on commit 2c45a3b

Please sign in to comment.