invert few if-else with negation for readability
Bartosz Kaszubowski committed
Jul 18, 2015 at 00:19 UTC
da11691e26c42ebed669b32c8fbda4b937aa04cd
4 files changed
+17
-17
src/renderers/shared/event/eventPlugins/ResponderTouchHistoryStore.js
+3
-3
@@ -105,10 +105,10 @@ var recordStartTouchData = function(touch) {
105
if (__DEV__) {
106
validateTouch(touch);
107
}
108
- if (!touchTrack) {
109
- touchBank[touch.identifier] = initializeTouchData(touch);
110
- } else {
108
+ if (touchTrack) {
109
reinitializeTouchTrack(touchTrack, touch);
110
+ } else {
111
+ touchBank[touch.identifier] = initializeTouchData(touch);
112
}
113
touchHistory.mostRecentTimeStamp = timestampForTouch(touch);
114
};
src/shared/utils/Transaction.js
+3
-3
@@ -84,10 +84,10 @@ var Mixin = {
84
*/
85
reinitializeTransaction: function() {
86
this.transactionWrappers = this.getTransactionWrappers();
87
- if (!this.wrapperInitData) {
88
- this.wrapperInitData = [];
89
- } else {
87
+ if (this.wrapperInitData) {
88
this.wrapperInitData.length = 0;
89
+ } else {
90
+ this.wrapperInitData = [];
91
}
92
this._isInTransaction = false;
93
},
src/shared/vendor/stubs/EventListener.js
+8
-8
@@ -59,7 +59,14 @@ var EventListener = {
59
* @return {object} Object with a `remove` method.
60
*/
61
capture: function(target, eventType, callback) {
62
- if (!target.addEventListener) {
62
+ if (target.addEventListener) {
63
+ target.addEventListener(eventType, callback, true);
64
+ return {
65
+ remove: function () {
66
+ target.removeEventListener(eventType, callback, true);
67
+ }
68
+ };
69
+ } else {
70
if (__DEV__) {
71
console.error(
72
'Attempted to listen to events during the capture phase on a ' +
@@ -70,13 +77,6 @@ var EventListener = {
77
return {
78
remove: emptyFunction
79
};
73
- } else {
74
- target.addEventListener(eventType, callback, true);
75
- return {
76
- remove: function() {
77
- target.removeEventListener(eventType, callback, true);
78
- }
79
- };
80
}
81
},
82
src/test/ReactTestUtils.js
+3
-3
@@ -410,7 +410,9 @@ ReactShallowRenderer.prototype.unmount = function() {
410
};
411
412
ReactShallowRenderer.prototype._render = function(element, transaction, context) {
413
- if (!this._instance) {
413
+ if (this._instance) {
414
+ this._instance.receiveComponent(element, transaction, context);
415
+ } else {
416
var rootID = ReactInstanceHandles.createReactRootID();
417
var instance = new ShallowComponentWrapper(element.type);
418
instance.construct(element);
@@ -418,8 +420,6 @@ ReactShallowRenderer.prototype._render = function(element, transaction, context)
420
instance.mountComponent(rootID, transaction, context);
421
422
this._instance = instance;
421
- } else {
422
- this._instance.receiveComponent(element, transaction, context);
423
}
424
};
425