From 7882533dafe3241a12f1340699730cbf00f63152 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=B0=D0=BD=D0=B8=D1=97=D0=BB=20=D0=93=D1=80=D0=B8?= =?UTF-8?q?=D0=B3=D0=BE=D1=80=27=D1=94=D0=B2?= Date: Mon, 23 Sep 2024 23:39:07 +0300 Subject: [PATCH] Fix TextualGameState HTML string fallback Move the additional wrapping for getMainContentHTML into getInnerHTML and call it from GameState super method. Also apply the same wrapping to getInitialContent (if not null) to ensure equal treatment of legacy HTML strings and modern JSX/TSX methods. --- src/js/core/textual_game_state.tsx | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/src/js/core/textual_game_state.tsx b/src/js/core/textual_game_state.tsx index 7462769e..8cc2a0d7 100644 --- a/src/js/core/textual_game_state.tsx +++ b/src/js/core/textual_game_state.tsx @@ -19,7 +19,11 @@ export abstract class TextualGameState extends GameState { * @deprecated */ getInnerHTML(): string { - return ""; + return ` +
+ ${this.getMainContentHTML()} +
+ `; } /** @@ -36,21 +40,8 @@ export abstract class TextualGameState extends GameState { * title, and content returned by {@link getInitialContent}. */ protected override getContentLayout(): Node { - let content = this.getInitialContent(); - - if (content === null) { - // Fall back either to getMainContentHTML or getInnerHTML (if not "") - let html = this.getInnerHTML(); - if (html === "") { - html = ` -
- ${this.getMainContentHTML()} -
- `; - } - - content = super.getContentLayout(); - } + const initialContent = this.getInitialContent(); + const content = initialContent !== null &&
{initialContent}
; return ( <> @@ -60,7 +51,7 @@ export abstract class TextualGameState extends GameState { {this.getStateHeaderTitle() ?? ""} -
{content}
+
{content || super.getContentLayout()}
); }