Skip to content

Commit

Permalink
Merge pull request facebook#4206 from yiminghe/fix_change_type
Browse files Browse the repository at this point in the history
Set change event type in SyntheticEvent
  • Loading branch information
jimfb committed Jun 24, 2015
2 parents b99fb2c + ee831d7 commit 484e20c
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/renderers/dom/client/eventPlugins/ChangeEventPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,7 @@ var ChangeEventPlugin = {
targetID,
nativeEvent
);
event.type = 'change';
EventPropagators.accumulateTwoPhaseDispatches(event);
return event;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/**
* Copyright 2013-2015, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @emails react-core
*/

'use strict';

var React = require('React');
var ReactTestUtils = require('ReactTestUtils');

describe('ChangeEventPlugin', function() {
it('should fire change for checkbox input', function() {
var called = 0;

function cb(e) {
called = 1;
expect(e.type).toBe('change');
}

var input = ReactTestUtils.renderIntoDocument(<input type="checkbox" onChange={cb}/>);
ReactTestUtils.SimulateNative.click(input);
expect(called).toBe(1);
});
});

0 comments on commit 484e20c

Please sign in to comment.