invert few if-else with negation for readability

This commit is contained in:
Bartosz Kaszubowski
2015-07-18 00:19:28 +02:00
parent cc85f42f0f
commit da11691e26
4 changed files with 17 additions and 17 deletions
@@ -105,10 +105,10 @@ var recordStartTouchData = function(touch) {
if (__DEV__) {
validateTouch(touch);
}
if (!touchTrack) {
touchBank[touch.identifier] = initializeTouchData(touch);
} else {
if (touchTrack) {
reinitializeTouchTrack(touchTrack, touch);
} else {
touchBank[touch.identifier] = initializeTouchData(touch);
}
touchHistory.mostRecentTimeStamp = timestampForTouch(touch);
};
+3 -3
View File
@@ -84,10 +84,10 @@ var Mixin = {
*/
reinitializeTransaction: function() {
this.transactionWrappers = this.getTransactionWrappers();
if (!this.wrapperInitData) {
this.wrapperInitData = [];
} else {
if (this.wrapperInitData) {
this.wrapperInitData.length = 0;
} else {
this.wrapperInitData = [];
}
this._isInTransaction = false;
},
+8 -8
View File
@@ -59,7 +59,14 @@ var EventListener = {
* @return {object} Object with a `remove` method.
*/
capture: function(target, eventType, callback) {
if (!target.addEventListener) {
if (target.addEventListener) {
target.addEventListener(eventType, callback, true);
return {
remove: function () {
target.removeEventListener(eventType, callback, true);
}
};
} else {
if (__DEV__) {
console.error(
'Attempted to listen to events during the capture phase on a ' +
@@ -70,13 +77,6 @@ var EventListener = {
return {
remove: emptyFunction
};
} else {
target.addEventListener(eventType, callback, true);
return {
remove: function() {
target.removeEventListener(eventType, callback, true);
}
};
}
},
+3 -3
View File
@@ -410,7 +410,9 @@ ReactShallowRenderer.prototype.unmount = function() {
};
ReactShallowRenderer.prototype._render = function(element, transaction, context) {
if (!this._instance) {
if (this._instance) {
this._instance.receiveComponent(element, transaction, context);
} else {
var rootID = ReactInstanceHandles.createReactRootID();
var instance = new ShallowComponentWrapper(element.type);
instance.construct(element);
@@ -418,8 +420,6 @@ ReactShallowRenderer.prototype._render = function(element, transaction, context)
instance.mountComponent(rootID, transaction, context);
this._instance = instance;
} else {
this._instance.receiveComponent(element, transaction, context);
}
};