@@ -112,6 +112,26 @@ async function buildHierarchyToggle() {
112
112
. stream ( )
113
113
. pipeThrough ( new DecompressionStream ( "gzip" ) ) ;
114
114
115
+ const baseReflId = + container . dataset . refl ! ;
116
+ const hierarchy : JsonHierarchy = await new Response ( json ) . json ( ) ;
117
+
118
+ const collapsedHierarchy = container . querySelector ( "ul" ) ! ;
119
+ const expandedHierarchy = document . createElement ( "ul" ) ;
120
+ expandedHierarchy . classList . add ( "tsd-hierarchy" ) ;
121
+ buildExpandedHierarchy ( expandedHierarchy , hierarchy , baseReflId ) ;
122
+
123
+ // No point in showing the expand button if it will be the same content.
124
+ // It won't be the exact same innerHTML due to links being generated less
125
+ // intelligently here than in the theme (though they still go to the same place)
126
+ // but if there are the same number of elements in the hierarchy, there's
127
+ // no point.
128
+ if (
129
+ collapsedHierarchy . querySelectorAll ( "li" ) . length ==
130
+ expandedHierarchy . querySelectorAll ( "li" ) . length
131
+ ) {
132
+ return ;
133
+ }
134
+
115
135
const expandCollapseButton = document . createElement ( "span" ) ;
116
136
expandCollapseButton . classList . add ( "tsd-hierarchy-toggle" ) ;
117
137
expandCollapseButton . textContent = window . translations . hierarchy_expand ;
@@ -141,14 +161,6 @@ async function buildHierarchyToggle() {
141
161
window . translations . hierarchy_expand ;
142
162
}
143
163
} ) ;
144
-
145
- const baseReflId = + container . dataset . refl ! ;
146
- const hierarchy : JsonHierarchy = await new Response ( json ) . json ( ) ;
147
-
148
- const collapsedHierarchy = container . querySelector ( "ul" ) ! ;
149
- const expandedHierarchy = document . createElement ( "ul" ) ;
150
- expandedHierarchy . classList . add ( "tsd-hierarchy" ) ;
151
- buildExpandedHierarchy ( expandedHierarchy , hierarchy , baseReflId ) ;
152
164
}
153
165
154
166
function buildExpandedHierarchy (
@@ -177,7 +189,7 @@ function followHierarchy(
177
189
178
190
const item = hierarchy . reflections [ id ] ;
179
191
const container = document . createElement ( "li" ) ;
180
- container . classList . add ( "tsd-hierarchy" ) ;
192
+ container . classList . add ( "tsd-hierarchy-item " ) ;
181
193
182
194
if ( id === targetId ) {
183
195
const text = container . appendChild ( document . createElement ( "span" ) ) ;
0 commit comments