Skip to content

Commit 9897066

Browse files
committed
Add test case for Chrome under 53
1 parent 54d73f1 commit 9897066

File tree

3 files changed

+32
-17
lines changed

3 files changed

+32
-17
lines changed

scripts/fiber/tests-passing.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1366,7 +1366,8 @@ src/renderers/dom/shared/eventPlugins/__tests__/ChangeEventPlugin-test.js
13661366
* should deduplicate input value change events
13671367
* should listen for both change and input events when supported
13681368
* should only fire events when the value changes for range inputs
1369-
* should only fire change once on Webkit
1369+
* should only fire change once on Chrome
1370+
* should only fire change once on Chrome under 53
13701371
* should only fire change once on Firefox
13711372
* should only fire change once on IE9
13721373
* should only fire change once on IE10

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

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -227,21 +227,12 @@ function getTargetInstForClickEvent(topLevelType, targetInst) {
227227
function getTargetInstForInputOrChangeEvent(topLevelType, targetInst) {
228228
if (inComposition(topLevelType)) {
229229
return;
230-
} else if (
231-
topLevelType === 'topInput' &&
232-
lastTopLevelType === 'topCompositionEnd'
233-
) {
230+
} else if (topLevelType === 'topInput' && lastTopLevelType === 'topCompositionEnd') {
234231
return getInstIfValueChanged(targetInst);
235-
} else if (
236-
// Webkit fires 'compositionEnd' event after 'input' event.
237-
topLevelType === 'topKeyUp' &&
238-
lastTopLevelType === 'topCompositionEnd'
239-
) {
232+
} else if (topLevelType === 'topKeyUp' && lastTopLevelType === 'topCompositionEnd') {
233+
// Chrome fires 'compositionEnd' event after 'input' event.
240234
return getInstIfValueChanged(targetInst);
241-
} else if (
242-
topLevelType === 'topInput' ||
243-
topLevelType === 'topChange'
244-
) {
235+
} else if (topLevelType === 'topInput' || topLevelType === 'topChange') {
245236
return getInstIfValueChanged(targetInst);
246237
}
247238
}

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

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,26 @@ describe('ChangeEventPlugin', () => {
248248
}
249249

250250
var Scenario = {
251-
Webkit: [
251+
ChromeUnder53: [
252+
{ run: setUntrackedValue, args: [ 'n' ] },
253+
{ run: simulateEvent, args: [ 'keyDown' ] },
254+
{ run: simulateEvent, args: [ 'compositionStart' ] },
255+
{ run: simulateEvent, args: [ 'compositionUpdate' ] },
256+
{ run: simulateEvent, args: [ 'input' ] },
257+
{ run: simulateEvent, args: [ 'keyUp' ] },
258+
{ run: setUntrackedValue, args: [ 'ni' ] },
259+
{ run: simulateEvent, args: [ 'keyDown' ] },
260+
{ run: simulateEvent, args: [ 'compositionUpdate' ] },
261+
{ run: simulateEvent, args: [ 'input' ] },
262+
{ run: simulateEvent, args: [ 'keyUp' ] },
263+
{ run: setUntrackedValue, args: [ '你' ] },
264+
{ run: simulateEvent, args: [ 'keyDown' ] },
265+
{ run: simulateEvent, args: [ 'compositionEnd' ] },
266+
{ run: simulateEvent, args: [ 'textInput' ] },
267+
{ run: simulateEvent, args: [ 'input' ] },
268+
{ run: simulateEvent, args: [ 'keyUp' ] },
269+
],
270+
Chrome: [
252271
{ run: setUntrackedValue, args: [ 'n' ] },
253272
{ run: simulateEvent, args: [ 'keyDown' ] },
254273
{ run: simulateEvent, args: [ 'compositionStart' ] },
@@ -348,8 +367,12 @@ describe('ChangeEventPlugin', () => {
348367
],
349368
};
350369

351-
it('should only fire change once on Webkit', () => {
352-
TestCompositionEvent(Scenario.Webkit);
370+
it('should only fire change once on Chrome', () => {
371+
TestCompositionEvent(Scenario.Chrome);
372+
});
373+
374+
it('should only fire change once on Chrome under 53', () => {
375+
TestCompositionEvent(Scenario.ChromeUnder53);
353376
});
354377

355378
it('should only fire change once on Firefox', () => {

0 commit comments

Comments
 (0)