fix change event type
yiminghe committed
Jun 24, 2015 at 17:06 UTC
47e9cfb975a44476d51eaff7e5be204dfaf856b4
2 files changed
+45
src/renderers/dom/client/eventPlugins/ChangeEventPlugin.js
+1
@@ -362,6 +362,7 @@ var ChangeEventPlugin = {
362
targetID,
363
nativeEvent
364
);
365
+ event.type = 'change';
366
EventPropagators.accumulateTwoPhaseDispatches(event);
367
return event;
368
}
src/renderers/dom/client/eventPlugins/__tests__/ChangeEventPlugin-test.js
new
+44
@@ -0,0 +1,44 @@
1
+/**
2
+ * Copyright 2013-2015, Facebook, Inc.
3
+ * All rights reserved.
4
+ *
5
+ * This source code is licensed under the BSD-style license found in the
6
+ * LICENSE file in the root directory of this source tree. An additional grant
7
+ * of patent rights can be found in the PATENTS file in the same directory.
8
+ *
9
+ * @emails react-core
10
+ */
11
+
12
+'use strict';
13
+
14
+var mocks = require('mocks');
15
+var React = require('React');
16
+
17
+describe('ChangeEventPlugin', function() {
18
+ var container;
19
+
20
+ beforeEach(function() {
21
+ container = document.createElement('div');
22
+ document.body.appendChild(container);
23
+ });
24
+
25
+ afterEach(function() {
26
+ React.unmountComponentAtNode(container);
27
+ document.body.removeChild(container);
28
+ });
29
+
30
+ it('should fire change for checkbox input', function() {
31
+ var called = 0;
32
+
33
+ function cb(e) {
34
+ called = 1;
35
+ expect(e.type).toBe('change');
36
+ }
37
+
38
+ var input = React.render(<input type="checkbox" onChange={cb}/>, container);
39
+ console.log(input);
40
+ console.log(React.findDOMNode(input));
41
+ React.findDOMNode(input).click();
42
+ expect(called).toBe(1);
43
+ });
44
+});