Skip to content

Commit

Permalink
Add test case for Chrome under 53
Browse files Browse the repository at this point in the history
  • Loading branch information
yesmeck committed Apr 2, 2017
1 parent 54d73f1 commit 9897066
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 17 deletions.
3 changes: 2 additions & 1 deletion scripts/fiber/tests-passing.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1366,7 +1366,8 @@ src/renderers/dom/shared/eventPlugins/__tests__/ChangeEventPlugin-test.js
* should deduplicate input value change events
* should listen for both change and input events when supported
* should only fire events when the value changes for range inputs
* should only fire change once on Webkit
* should only fire change once on Chrome
* should only fire change once on Chrome under 53
* should only fire change once on Firefox
* should only fire change once on IE9
* should only fire change once on IE10
Expand Down
17 changes: 4 additions & 13 deletions src/renderers/dom/shared/eventPlugins/ChangeEventPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,21 +227,12 @@ function getTargetInstForClickEvent(topLevelType, targetInst) {
function getTargetInstForInputOrChangeEvent(topLevelType, targetInst) {
if (inComposition(topLevelType)) {
return;
} else if (
topLevelType === 'topInput' &&
lastTopLevelType === 'topCompositionEnd'
) {
} else if (topLevelType === 'topInput' && lastTopLevelType === 'topCompositionEnd') {
return getInstIfValueChanged(targetInst);
} else if (
// Webkit fires 'compositionEnd' event after 'input' event.
topLevelType === 'topKeyUp' &&
lastTopLevelType === 'topCompositionEnd'
) {
} else if (topLevelType === 'topKeyUp' && lastTopLevelType === 'topCompositionEnd') {
// Chrome fires 'compositionEnd' event after 'input' event.
return getInstIfValueChanged(targetInst);
} else if (
topLevelType === 'topInput' ||
topLevelType === 'topChange'
) {
} else if (topLevelType === 'topInput' || topLevelType === 'topChange') {
return getInstIfValueChanged(targetInst);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,26 @@ describe('ChangeEventPlugin', () => {
}

var Scenario = {
Webkit: [
ChromeUnder53: [
{ run: setUntrackedValue, args: [ 'n' ] },
{ run: simulateEvent, args: [ 'keyDown' ] },
{ run: simulateEvent, args: [ 'compositionStart' ] },
{ run: simulateEvent, args: [ 'compositionUpdate' ] },
{ run: simulateEvent, args: [ 'input' ] },
{ run: simulateEvent, args: [ 'keyUp' ] },
{ run: setUntrackedValue, args: [ 'ni' ] },
{ run: simulateEvent, args: [ 'keyDown' ] },
{ run: simulateEvent, args: [ 'compositionUpdate' ] },
{ run: simulateEvent, args: [ 'input' ] },
{ run: simulateEvent, args: [ 'keyUp' ] },
{ run: setUntrackedValue, args: [ '你' ] },
{ run: simulateEvent, args: [ 'keyDown' ] },
{ run: simulateEvent, args: [ 'compositionEnd' ] },
{ run: simulateEvent, args: [ 'textInput' ] },
{ run: simulateEvent, args: [ 'input' ] },
{ run: simulateEvent, args: [ 'keyUp' ] },
],
Chrome: [
{ run: setUntrackedValue, args: [ 'n' ] },
{ run: simulateEvent, args: [ 'keyDown' ] },
{ run: simulateEvent, args: [ 'compositionStart' ] },
Expand Down Expand Up @@ -348,8 +367,12 @@ describe('ChangeEventPlugin', () => {
],
};

it('should only fire change once on Webkit', () => {
TestCompositionEvent(Scenario.Webkit);
it('should only fire change once on Chrome', () => {
TestCompositionEvent(Scenario.Chrome);
});

it('should only fire change once on Chrome under 53', () => {
TestCompositionEvent(Scenario.ChromeUnder53);
});

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

0 comments on commit 9897066

Please sign in to comment.