Skip to content

Commit

Permalink
Fix crash when class implements itself
Browse files Browse the repository at this point in the history
Resolves #2495
  • Loading branch information
Gerrit0 committed Feb 7, 2024
1 parent eb7510b commit e76d594
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
## Bug Fixes

- Fixed an issue where a namespace would not be created for merged function-namespaces which are declared as variables, #2478.
- A class which implements itself will no longer cause a crash when rendering HTML, #2495.
- Variable functions which have construct signatures will no longer be converted as functions, ignoring the construct signatures.
- Fixed an issue where, if the index section was collapsed when loading the page, all content within it would be hidden until expanded, and a member visibility checkbox was changed.

Expand Down
13 changes: 10 additions & 3 deletions src/lib/output/themes/default/templates/hierarchy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,14 @@ import type { PageEvent } from "../../../events";
import { JSX } from "../../../../utils";
import { ReflectionKind, type ProjectReflection, DeclarationReflection } from "../../../../models";

function fullHierarchy(context: DefaultThemeRenderContext, root: DeclarationReflection) {
function fullHierarchy(
context: DefaultThemeRenderContext,
root: DeclarationReflection,
seen = new Set<DeclarationReflection>(),
) {
if (seen.has(root)) return;
seen.add(root);

// Note: We don't use root.anchor for the anchor, because those are built on a per page basis.
// And classes/interfaces get their own page, so all the anchors will be empty anyways.
// Full name should be safe here, since this list only includes classes/interfaces.
Expand All @@ -16,10 +23,10 @@ function fullHierarchy(context: DefaultThemeRenderContext, root: DeclarationRefl
</a>
<ul>
{root.implementedBy?.map((child) => {
return child.reflection && fullHierarchy(context, child.reflection as DeclarationReflection);
return child.reflection && fullHierarchy(context, child.reflection as DeclarationReflection, seen);
})}
{root.extendedBy?.map((child) => {
return child.reflection && fullHierarchy(context, child.reflection as DeclarationReflection);
return child.reflection && fullHierarchy(context, child.reflection as DeclarationReflection, seen);
})}
</ul>
</li>
Expand Down

0 comments on commit e76d594

Please sign in to comment.