@@ -55,25 +55,29 @@ export class InvisibleElementsPanel extends Component {
55
55
// └ descendantInvisibleSnippet
56
56
// └ descendantOfDescendantInvisibleSnippet
57
57
// └ etc...
58
- const createInvisibleEntries = ( snippetEls , isDescendant ) =>
58
+ const createInvisibleEntries = ( snippetEls , parentEl = null ) =>
59
59
snippetEls . map ( ( snippetEl ) => {
60
60
const descendantSnippetEls = descendantPerSnippet . get ( snippetEl ) ;
61
61
// An element is considered as "RootParent" if it has one or
62
62
// more invisible descendants but is not a descendant.
63
63
const invisibleElement = {
64
64
snippetEl : snippetEl ,
65
65
name : getSnippetName ( snippetEl ) ,
66
- isRootParent : ! isDescendant && ! ! descendantSnippetEls ,
67
- isDescendant,
66
+ isRootParent : ! parentEl && ! ! descendantSnippetEls ,
67
+ isDescendant : ! ! parentEl ,
68
68
isVisible : snippetEl . dataset . invisible !== "1" ,
69
69
children : [ ] ,
70
+ parentEl,
70
71
} ;
71
72
if ( descendantSnippetEls ) {
72
- invisibleElement . children = createInvisibleEntries ( descendantSnippetEls , true ) ;
73
+ invisibleElement . children = createInvisibleEntries (
74
+ descendantSnippetEls ,
75
+ invisibleElement
76
+ ) ;
73
77
}
74
78
return invisibleElement ;
75
79
} ) ;
76
- this . state . invisibleEntries = createInvisibleEntries ( rootInvisibleSnippetEls , false ) ;
80
+ this . state . invisibleEntries = createInvisibleEntries ( rootInvisibleSnippetEls ) ;
77
81
}
78
82
79
83
toggleElementVisibility ( invisibleEntry ) {
@@ -97,10 +101,10 @@ export class InvisibleElementsPanel extends Component {
97
101
this . toggleElementVisibility ( child ) ;
98
102
}
99
103
} ) ;
100
- } else if ( invisibleEntry . parents && ! invisibleEntry . parents . isVisible ) {
104
+ } else if ( invisibleEntry . parentEl && ! invisibleEntry . parentEl . isVisible ) {
101
105
// When toggling the visibility of an element to "Show", also toggle
102
106
// all its parents.
103
- this . toggleElementVisibility ( invisibleEntry . parents ) ;
107
+ this . toggleElementVisibility ( invisibleEntry . parentEl ) ;
104
108
}
105
109
toggleVisibility ( invisibleEntry . snippetEl ) ;
106
110
}
0 commit comments