1
0
mirror of https://github.com/tobspr/shapez.io.git synced 2025-12-11 09:11:50 +00:00

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.
This commit is contained in:
Даниїл Григор'єв 2024-09-23 23:39:07 +03:00
parent 7dac0baa6b
commit 7882533daf
No known key found for this signature in database
GPG Key ID: B890DF16341D8C1D

View File

@ -19,7 +19,11 @@ export abstract class TextualGameState extends GameState {
* @deprecated
*/
getInnerHTML(): string {
return "";
return `
<div class="content mainContent">
${this.getMainContentHTML()}
</div>
`;
}
/**
@ -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 = `
<div class="content mainContent">
${this.getMainContentHTML()}
</div>
`;
}
content = super.getContentLayout();
}
const initialContent = this.getInitialContent();
const content = initialContent !== null && <div class="content mainContent">{initialContent}</div>;
return (
<>
@ -60,7 +51,7 @@ export abstract class TextualGameState extends GameState {
{this.getStateHeaderTitle() ?? ""}
</h1>
</div>
<div class="container">{content}</div>
<div class="container">{content || super.getContentLayout()}</div>
</>
);
}