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 11# CHANGELOG
22
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+
39## [ v1.1.0] ( https://github.com/jakezatecky/react-checkbox-tree/compare/v1.0.2...v1.1.0 ) (2018-03-31)
410
511### New Features
Original file line number Diff line number Diff line change @@ -164,7 +164,9 @@ class CheckboxTree extends React.Component {
164164 // Unserialize values and set their nodes to true
165165 Object . keys ( lists ) . forEach ( ( listKey ) => {
166166 lists [ listKey ] . forEach ( ( value ) => {
167- this . nodes [ value ] [ listKey ] = true ;
167+ if ( this . nodes [ value ] !== undefined ) {
168+ this . nodes [ value ] [ listKey ] = true ;
169+ }
168170 } ) ;
169171 } ) ;
170172 }
Original file line number Diff line number Diff line change @@ -22,6 +22,19 @@ describe('<CheckboxTree />', () => {
2222 } ) ;
2323 } ) ;
2424
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+
2538 describe ( 'disabled' , ( ) => {
2639 it ( 'should add the class rct-disabled to the root' , ( ) => {
2740 const wrapper = shallow (
@@ -32,6 +45,19 @@ describe('<CheckboxTree />', () => {
3245 } ) ;
3346 } ) ;
3447
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+
3561 describe ( 'nativeCheckboxes' , ( ) => {
3662 it ( 'should add the class rct-native-display to the root' , ( ) => {
3763 const wrapper = shallow (
You can’t perform that action at this time.
0 commit comments