Skip to content

Commit 1d7971a

Browse files
committed
Run prettier
1 parent 68347c9 commit 1d7971a

File tree

6 files changed

+76
-94
lines changed

6 files changed

+76
-94
lines changed

src/renderers/dom/client/__tests__/inputValueTracking-test.js

Lines changed: 24 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -22,23 +22,21 @@ describe('inputValueTracking', function() {
2222
input.type = 'text';
2323
checkbox = document.createElement('input');
2424
checkbox.type = 'checkbox';
25-
mockComponent = { _hostNode: input, _wrapperState: {} };
25+
mockComponent = {_hostNode: input, _wrapperState: {}};
2626
});
2727

2828
it('should attach tracker to wrapper state', function() {
2929
inputValueTracking.track(mockComponent);
3030

31-
expect(
32-
mockComponent._wrapperState.hasOwnProperty('valueTracker')
33-
).toBe(true);
31+
expect(mockComponent._wrapperState.hasOwnProperty('valueTracker')).toBe(
32+
true,
33+
);
3434
});
3535

3636
it('should define `value` on the instance node', function() {
3737
inputValueTracking.track(mockComponent);
3838

39-
expect(
40-
input.hasOwnProperty('value')
41-
).toBe(true);
39+
expect(input.hasOwnProperty('value')).toBe(true);
4240
});
4341

4442
it('should define `checked` on the instance node', function() {
@@ -49,7 +47,7 @@ describe('inputValueTracking', function() {
4947
});
5048

5149
it('should initialize with the current value', function() {
52-
input.value ='foo';
50+
input.value = 'foo';
5351

5452
inputValueTracking.track(mockComponent);
5553

@@ -69,13 +67,13 @@ describe('inputValueTracking', function() {
6967
});
7068

7169
it('should track value changes', function() {
72-
input.value ='foo';
70+
input.value = 'foo';
7371

7472
inputValueTracking.track(mockComponent);
7573

7674
var tracker = mockComponent._wrapperState.valueTracker;
7775

78-
input.value ='bar';
76+
input.value = 'bar';
7977
expect(tracker.getValue()).toEqual('bar');
8078
});
8179

@@ -91,7 +89,7 @@ describe('inputValueTracking', function() {
9189
});
9290

9391
it('should update value manually', function() {
94-
input.value ='foo';
92+
input.value = 'foo';
9593
inputValueTracking.track(mockComponent);
9694

9795
var tracker = mockComponent._wrapperState.valueTracker;
@@ -101,7 +99,7 @@ describe('inputValueTracking', function() {
10199
});
102100

103101
it('should coerce value to a string', function() {
104-
input.value ='foo';
102+
input.value = 'foo';
105103
inputValueTracking.track(mockComponent);
106104

107105
var tracker = mockComponent._wrapperState.valueTracker;
@@ -112,53 +110,48 @@ describe('inputValueTracking', function() {
112110

113111
it('should update value if it changed and return result', function() {
114112
inputValueTracking.track(mockComponent);
115-
input.value ='foo';
113+
input.value = 'foo';
116114

117115
var tracker = mockComponent._wrapperState.valueTracker;
118116

119-
expect(
120-
inputValueTracking.updateValueIfChanged(mockComponent)
121-
).toBe(false);
117+
expect(inputValueTracking.updateValueIfChanged(mockComponent)).toBe(false);
122118

123119
tracker.setValue('bar');
124120

125-
expect(
126-
inputValueTracking.updateValueIfChanged(mockComponent)
127-
).toBe(true);
121+
expect(inputValueTracking.updateValueIfChanged(mockComponent)).toBe(true);
128122

129123
expect(tracker.getValue()).toEqual('foo');
130124
});
131125

132126
it('should track value and return true when updating untracked instance', function() {
133-
input.value ='foo';
127+
input.value = 'foo';
134128

135-
expect(
136-
inputValueTracking.updateValueIfChanged(mockComponent)
137-
)
138-
.toBe(true);
129+
expect(inputValueTracking.updateValueIfChanged(mockComponent)).toBe(true);
139130

140131
var tracker = mockComponent._wrapperState.valueTracker;
141132
expect(tracker.getValue()).toEqual('foo');
142133
});
143134

144135
it('should return tracker from node', function() {
145-
var node = ReactTestUtils.renderIntoDocument(<input type="text" defaultValue="foo" />);
136+
var node = ReactTestUtils.renderIntoDocument(
137+
<input type="text" defaultValue="foo" />,
138+
);
146139
var tracker = inputValueTracking._getTrackerFromNode(node);
147140
expect(tracker.getValue()).toEqual('foo');
148141
});
149142

150143
it('should stop tracking', function() {
151144
inputValueTracking.track(mockComponent);
152145

153-
expect(
154-
mockComponent._wrapperState.hasOwnProperty('valueTracker')
155-
).toBe(true);
146+
expect(mockComponent._wrapperState.hasOwnProperty('valueTracker')).toBe(
147+
true,
148+
);
156149

157150
inputValueTracking.stopTracking(mockComponent);
158151

159-
expect(
160-
mockComponent._wrapperState.hasOwnProperty('valueTracker')
161-
).toBe(false);
152+
expect(mockComponent._wrapperState.hasOwnProperty('valueTracker')).toBe(
153+
false,
154+
);
162155

163156
expect(input.hasOwnProperty('value')).toBe(false);
164157
});

src/renderers/dom/client/eventPlugins/ChangeEventPlugin.js

Lines changed: 18 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ var getEventTarget = require('getEventTarget');
2323
var isEventSupported = require('isEventSupported');
2424
var isTextInputElement = require('isTextInputElement');
2525

26-
2726
var eventTypes = {
2827
change: {
2928
phasedRegistrationNames: {
@@ -48,7 +47,7 @@ function createAndAccumulateChangeEvent(inst, nativeEvent, target) {
4847
eventTypes.change,
4948
inst,
5049
nativeEvent,
51-
target
50+
target,
5251
);
5352
event.type = 'change';
5453
EventPropagators.accumulateTwoPhaseDispatches(event);
@@ -60,8 +59,6 @@ function createAndAccumulateChangeEvent(inst, nativeEvent, target) {
6059
var activeElement = null;
6160
var activeElementInst = null;
6261

63-
64-
6562
/**
6663
* SECTION: handle `change` event
6764
*/
@@ -121,21 +118,18 @@ function stopWatchingForChangeEventIE8() {
121118
activeElementInst = null;
122119
}
123120

124-
125121
function getInstIfValueChanged(targetInst, nativeEvent) {
126122
var updated = inputValueTracking.updateValueIfChanged(targetInst);
127-
var simulated = (
123+
var simulated =
128124
nativeEvent.simulated === true &&
129-
ChangeEventPlugin._allowSimulatedPassThrough
130-
);
125+
ChangeEventPlugin._allowSimulatedPassThrough;
131126

132127
if (updated || simulated) {
133128
return targetInst;
134129
}
135130
}
136131

137132
function getTargetInstForChangeEvent(topLevelType, targetInst) {
138-
139133
if (topLevelType === 'topChange') {
140134
return targetInst;
141135
}
@@ -160,13 +154,11 @@ if (ExecutionEnvironment.canUseDOM) {
160154
// IE9 claims to support the input event but fails to trigger it when
161155
// deleting text, so we ignore its input events.
162156

163-
isInputEventSupported = isEventSupported('input') && (
164-
!('documentMode' in document) || document.documentMode > 9
165-
);
166-
157+
isInputEventSupported =
158+
isEventSupported('input') &&
159+
(!('documentMode' in document) || document.documentMode > 9);
167160
}
168161

169-
170162
/**
171163
* (For IE <=9) Starts tracking propertychange events on the passed-in element
172164
* and override the value property so that we can distinguish user events from
@@ -205,13 +197,7 @@ function handlePropertyChange(nativeEvent) {
205197
}
206198
}
207199

208-
209-
function handleEventsForInputEventPolyfill(
210-
topLevelType,
211-
target,
212-
targetInst
213-
) {
214-
200+
function handleEventsForInputEventPolyfill(topLevelType, target, targetInst) {
215201
if (topLevelType === 'topFocus') {
216202
// In IE8, we can capture almost all .value changes by adding a
217203
// propertychange handler and looking for events with propertyName
@@ -237,11 +223,13 @@ function handleEventsForInputEventPolyfill(
237223
function getTargetInstForInputEventPolyfill(
238224
topLevelType,
239225
targetInst,
240-
nativeEvent
226+
nativeEvent,
241227
) {
242-
if (topLevelType === 'topSelectionChange' ||
243-
topLevelType === 'topKeyUp' ||
244-
topLevelType === 'topKeyDown') {
228+
if (
229+
topLevelType === 'topSelectionChange' ||
230+
topLevelType === 'topKeyUp' ||
231+
topLevelType === 'topKeyDown'
232+
) {
245233
// On the selectionchange event, the target is just document which isn't
246234
// helpful for us so just check activeElement instead.
247235
//
@@ -265,17 +253,13 @@ function shouldUseClickEvent(elem) {
265253
// until `blur` in IE8.
266254
var nodeName = elem.nodeName;
267255
return (
268-
(nodeName && nodeName.toLowerCase() === 'input') &&
256+
nodeName &&
257+
nodeName.toLowerCase() === 'input' &&
269258
(elem.type === 'checkbox' || elem.type === 'radio')
270259
);
271260
}
272261

273-
function getTargetInstForClickEvent(
274-
topLevelType,
275-
targetInst,
276-
nativeEvent
277-
) {
278-
262+
function getTargetInstForClickEvent(topLevelType, targetInst, nativeEvent) {
279263
if (topLevelType === 'topClick') {
280264
return getInstIfValueChanged(targetInst, nativeEvent);
281265
}
@@ -284,12 +268,9 @@ function getTargetInstForClickEvent(
284268
function getTargetInstForInputOrChangeEvent(
285269
topLevelType,
286270
targetInst,
287-
nativeEvent
271+
nativeEvent,
288272
) {
289-
if (
290-
topLevelType === 'topInput' ||
291-
topLevelType === 'topChange'
292-
) {
273+
if (topLevelType === 'topInput' || topLevelType === 'topChange') {
293274
return getInstIfValueChanged(targetInst, nativeEvent);
294275
}
295276
}

src/renderers/dom/client/eventPlugins/__tests__/ChangeEventPlugin-test.js

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,9 @@ describe('ChangeEventPlugin', () => {
5656
expect(e.type).toBe('change');
5757
}
5858

59-
var input = ReactTestUtils.renderIntoDocument(<input type="checkbox" onChange={cb}/>);
59+
var input = ReactTestUtils.renderIntoDocument(
60+
<input type="checkbox" onChange={cb} />,
61+
);
6062

6163
setUntrackedValue(input, true);
6264
ReactTestUtils.SimulateNative.click(input);
@@ -66,7 +68,7 @@ describe('ChangeEventPlugin', () => {
6668

6769
it('should catch setting the value programmatically', function() {
6870
var input = ReactTestUtils.renderIntoDocument(
69-
<input type="text" defaultValue="foo"/>
71+
<input type="text" defaultValue="foo" />,
7072
);
7173

7274
input.value = 'bar';
@@ -82,7 +84,7 @@ describe('ChangeEventPlugin', () => {
8284
}
8385

8486
var input = ReactTestUtils.renderIntoDocument(
85-
<input type="text" onChange={cb} defaultValue="foo"/>
87+
<input type="text" onChange={cb} defaultValue="foo" />,
8688
);
8789

8890
input.value = 'bar';
@@ -104,7 +106,7 @@ describe('ChangeEventPlugin', () => {
104106
}
105107

106108
var input = ReactTestUtils.renderIntoDocument(
107-
<input type="checkbox" onChange={cb} defaultChecked={true} />
109+
<input type="checkbox" onChange={cb} defaultChecked={true} />,
108110
);
109111

110112
input.checked = true;
@@ -132,7 +134,9 @@ describe('ChangeEventPlugin', () => {
132134
called += 1;
133135
}
134136

135-
var input = ReactTestUtils.renderIntoDocument(<input type="radio" onChange={cb}/>);
137+
var input = ReactTestUtils.renderIntoDocument(
138+
<input type="radio" onChange={cb} />,
139+
);
136140
setUntrackedValue(input, true);
137141
ReactTestUtils.SimulateNative.click(input);
138142
ReactTestUtils.SimulateNative.click(input);
@@ -149,9 +153,9 @@ describe('ChangeEventPlugin', () => {
149153
}
150154

151155
[
152-
<input type="text" onChange={cb}/>,
153-
<input type="number" onChange={cb}/>,
154-
<input type="range" onChange={cb}/>,
156+
<input type="text" onChange={cb} />,
157+
<input type="number" onChange={cb} />,
158+
<input type="range" onChange={cb} />,
155159
].forEach(function(element) {
156160
called = 0;
157161
input = ReactTestUtils.renderIntoDocument(element);
@@ -189,7 +193,9 @@ describe('ChangeEventPlugin', () => {
189193
return;
190194
}
191195

192-
var input = ReactTestUtils.renderIntoDocument(<input type="range" onChange={cb}/>);
196+
var input = ReactTestUtils.renderIntoDocument(
197+
<input type="range" onChange={cb} />,
198+
);
193199
setUntrackedValue(input, 'bar');
194200

195201
ReactTestUtils.SimulateNative.input(input);
@@ -209,7 +215,9 @@ describe('ChangeEventPlugin', () => {
209215
expect(e.type).toBe('change');
210216
}
211217

212-
var input = ReactTestUtils.renderIntoDocument(<input type="range" onChange={cb}/>);
218+
var input = ReactTestUtils.renderIntoDocument(
219+
<input type="range" onChange={cb} />,
220+
);
213221
setUntrackedValue(input, '40');
214222
ReactTestUtils.SimulateNative.input(input);
215223
ReactTestUtils.SimulateNative.change(input);

0 commit comments

Comments
 (0)