3
3
*/
4
4
var React = require ( 'react' ) ;
5
5
6
- var CheckboxGroup = module . exports = React . createClass ( {
6
+ module . exports = React . createClass ( {
7
+ displayName : 'CheckboxGroup' ,
7
8
getInitialState : function ( ) {
8
9
return { defaultValue : this . props . defaultValue || [ ] } ;
9
10
} ,
@@ -19,8 +20,8 @@ var CheckboxGroup = module.exports = React.createClass({
19
20
} ,
20
21
21
22
render : function ( ) {
22
- return this . transferPropsTo (
23
- < div onChange = { this . props . onChange } >
23
+ return (
24
+ < div { ... this . props } >
24
25
{ this . props . children }
25
26
</ div >
26
27
) ;
@@ -29,8 +30,8 @@ var CheckboxGroup = module.exports = React.createClass({
29
30
setCheckboxNames : function ( ) {
30
31
// stay DRY and don't put the same `name` on all checkboxes manually. Put it on
31
32
// the tag and it'll be done here
32
- var $checkboxes = this . getCheckboxes ( ) ;
33
- for ( var i = 0 , length = $checkboxes . length ; i < length ; i ++ ) {
33
+ let $checkboxes = this . getCheckboxes ( ) ;
34
+ for ( let i = 0 , length = $checkboxes . length ; i < length ; i ++ ) {
34
35
$checkboxes [ i ] . setAttribute ( 'name' , this . props . name ) ;
35
36
}
36
37
} ,
@@ -40,18 +41,18 @@ var CheckboxGroup = module.exports = React.createClass({
40
41
} ,
41
42
42
43
setCheckedBoxes : function ( ) {
43
- var $checkboxes = this . getCheckboxes ( ) ;
44
+ let $checkboxes = this . getCheckboxes ( ) ;
44
45
// if `value` is passed from parent, always use that value. This is similar
45
46
// to React's controlled component. If `defaultValue` is used instead,
46
47
// subsequent updates to defaultValue are ignored. Note: when `defaultValue`
47
48
// and `value` are both passed, the latter takes precedence, just like in
48
49
// a controlled component
49
- var destinationValue = this . props . value != null
50
+ let destinationValue = this . props . value != null
50
51
? this . props . value
51
52
: this . state . defaultValue ;
52
53
53
- for ( var i = 0 , length = $checkboxes . length ; i < length ; i ++ ) {
54
- var $checkbox = $checkboxes [ i ] ;
54
+ for ( let i = 0 , length = $checkboxes . length ; i < length ; i ++ ) {
55
+ let $checkbox = $checkboxes [ i ] ;
55
56
56
57
// intentionally use implicit conversion for those who accidentally used,
57
58
// say, `valueToChange` of 1 (integer) to compare it with `value` of "1"
@@ -63,10 +64,10 @@ var CheckboxGroup = module.exports = React.createClass({
63
64
} ,
64
65
65
66
getCheckedValues : function ( ) {
66
- var $checkboxes = this . getCheckboxes ( ) ;
67
+ let $checkboxes = this . getCheckboxes ( ) ;
67
68
68
- var checked = [ ] ;
69
- for ( var i = 0 , length = $checkboxes . length ; i < length ; i ++ ) {
69
+ let checked = [ ] ;
70
+ for ( let i = 0 , length = $checkboxes . length ; i < length ; i ++ ) {
70
71
if ( $checkboxes [ i ] . checked ) {
71
72
checked . push ( $checkboxes [ i ] . value ) ;
72
73
}
0 commit comments