mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
invert few if-else with negation for readability
This commit is contained in:
@@ -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);
|
||||
};
|
||||
|
||||
@@ -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
@@ -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);
|
||||
}
|
||||
};
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user