Skip to content

Conversation

Copy link

Copilot AI commented Dec 22, 2025

Style tags were accumulating in document.head each time a dialog was loaded, causing the style sheet to grow indefinitely.

Root Cause

In loadScreen(), old style tags were removed only for regular scenes:

if (!isDialog) {
  // Remove old style tags
  const styleTags = document.head.getElementsByTagName('style')
  for (const styleTag of styleTags) {
    document.head.removeChild(styleTag)
  }
}
// But always append new style tag
const styleElement = doc.head.getElementsByTagName('style')[0]
document.head.appendChild(styleElement)  // ← Appends every time

Changes

  • Moved style tag insertion inside the !isDialog block
  • Dialogs now inherit parent page styles without injecting duplicates
  • Added null check for templates without style tags
if (!isDialog) {
  // Remove old style tags
  const styleTags = document.head.getElementsByTagName('style')
  for (const styleTag of styleTags) {
    document.head.removeChild(styleTag)
  }
  this.gameContainer.innerHTML = mainDiv.innerHTML
  this.drawer.setScreen(this.gameContainer, engineConfig.resolution)
  // Only append style tag for regular scenes
  const styleElement = doc.head.getElementsByTagName('style')[0]
  if (styleElement) {
    document.head.appendChild(styleElement)
  }
} else {
  this.gameContainer.appendChild(mainDiv)
}
Original prompt

This section details on the original issue you should resolve

<issue_title>Styleタグが増殖する</issue_title>
<issue_description>


Trelloから移行 (doing): https://trello.com/c/J1KHS9hw</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits December 22, 2025 04:56
Co-authored-by: EndoHizumi <5486808+EndoHizumi@users.noreply.github.com>
Co-authored-by: EndoHizumi <5486808+EndoHizumi@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix issue of proliferating style tags Fix style tag accumulation when loading dialogs Dec 22, 2025
Copilot AI requested a review from EndoHizumi December 22, 2025 05:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Styleタグが増殖する

2 participants