File tree Expand file tree Collapse file tree 3 files changed +35
-1
lines changed Expand file tree Collapse file tree 3 files changed +35
-1
lines changed Original file line number Diff line number Diff line change 1
1
# CHANGELOG
2
2
3
+ ## v1.2.0 (TBA)
4
+
5
+ ### Other
6
+
7
+ * [ #69 ] : Tree will no longer throw an exception if ` checked ` or ` expanded ` contains values that do not recursively exist in the ` nodes ` property
8
+
3
9
## [ v1.1.0] ( https://github.com/jakezatecky/react-checkbox-tree/compare/v1.0.2...v1.1.0 ) (2018-03-31)
4
10
5
11
### New Features
Original file line number Diff line number Diff line change @@ -164,7 +164,9 @@ class CheckboxTree extends React.Component {
164
164
// Unserialize values and set their nodes to true
165
165
Object . keys ( lists ) . forEach ( ( listKey ) => {
166
166
lists [ listKey ] . forEach ( ( value ) => {
167
- this . nodes [ value ] [ listKey ] = true ;
167
+ if ( this . nodes [ value ] !== undefined ) {
168
+ this . nodes [ value ] [ listKey ] = true ;
169
+ }
168
170
} ) ;
169
171
} ) ;
170
172
}
Original file line number Diff line number Diff line change @@ -22,6 +22,19 @@ describe('<CheckboxTree />', () => {
22
22
} ) ;
23
23
} ) ;
24
24
25
+ describe ( 'checked' , ( ) => {
26
+ it ( 'should not throw an exception if it contains values that are not in the `nodes` property' , ( ) => {
27
+ const wrapper = shallow (
28
+ < CheckboxTree
29
+ checked = { [ 'neptune' ] }
30
+ nodes = { [ { value : 'jupiter' , label : 'Jupiter' } ] }
31
+ /> ,
32
+ ) ;
33
+
34
+ assert . isTrue ( wrapper . find ( '.react-checkbox-tree' ) . exists ( ) ) ;
35
+ } ) ;
36
+ } ) ;
37
+
25
38
describe ( 'disabled' , ( ) => {
26
39
it ( 'should add the class rct-disabled to the root' , ( ) => {
27
40
const wrapper = shallow (
@@ -32,6 +45,19 @@ describe('<CheckboxTree />', () => {
32
45
} ) ;
33
46
} ) ;
34
47
48
+ describe ( 'expanded' , ( ) => {
49
+ it ( 'should not throw an exception if it contains values that are not in the `nodes` property' , ( ) => {
50
+ const wrapper = shallow (
51
+ < CheckboxTree
52
+ expanded = { [ 'mars' ] }
53
+ nodes = { [ { value : 'jupiter' , label : 'Jupiter' } ] }
54
+ /> ,
55
+ ) ;
56
+
57
+ assert . isTrue ( wrapper . find ( '.react-checkbox-tree' ) . exists ( ) ) ;
58
+ } ) ;
59
+ } ) ;
60
+
35
61
describe ( 'nativeCheckboxes' , ( ) => {
36
62
it ( 'should add the class rct-native-display to the root' , ( ) => {
37
63
const wrapper = shallow (
You can’t perform that action at this time.
0 commit comments