Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUGFIX beta] avoid toBoolean conversion when possible (chains) #15107

Merged
merged 1 commit into from
Apr 4, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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