()
| 170 | $content._fileTree = null; |
| 171 | |
| 172 | const toggle = async () => { |
| 173 | const isExpanded = !$wrapper.classList.contains("hidden"); |
| 174 | |
| 175 | if (isExpanded) { |
| 176 | // Collapse |
| 177 | $wrapper.classList.add("hidden"); |
| 178 | |
| 179 | if (childTree) { |
| 180 | childTree.destroy(); |
| 181 | this.childTrees.delete(url); |
| 182 | childTree = null; |
| 183 | $content._fileTree = null; |
| 184 | } |
| 185 | this.options.onExpandedChange?.(url, false); |
| 186 | } else { |
| 187 | // Expand |
| 188 | $wrapper.classList.remove("hidden"); |
| 189 | $title.classList.add("loading"); |
| 190 | |
| 191 | // Create child tree with incremented depth |
| 192 | childTree = new FileTree($content, { |
| 193 | ...this.options, |
| 194 | _depth: this.depth + 1, |
| 195 | }); |
| 196 | this.childTrees.set(url, childTree); |
| 197 | $content._fileTree = childTree; |
| 198 | try { |
| 199 | await childTree.load(url); |
| 200 | } finally { |
| 201 | $title.classList.remove("loading"); |
| 202 | } |
| 203 | this.options.onExpandedChange?.(url, true); |
| 204 | } |
| 205 | }; |
| 206 | |
| 207 | $title.addEventListener("click", (e) => { |
| 208 | e.stopPropagation(); |
no test coverage detected