fix chat highlights (#92589)

## About The Pull Request
If we always define the fragment, the if after the loop will always
pass.
## Why It's Good For The Game
fixes #92468
<img width="653" height="223" alt="grafik"
src="https://github.com/user-attachments/assets/7995b73d-f648-4cbd-b05e-c36f98cab47b"
/>
## Changelog
🆑
fix: chat highlights
/🆑
This commit is contained in:
Kashargul
2025-08-17 03:33:53 +02:00
committed by GitHub
parent 07ec7a422e
commit 0221880d79

View File

@@ -27,9 +27,9 @@ function regexParseNode(params: ReplaceInTextNodeParams): {
return { nodes: [], n: 0 };
}
const fragment = document.createDocumentFragment();
const nodes: Node[] = [];
const textLength = text.length;
let fragment: Node | undefined;
let count = 0;
let lastIndex = 0;
let match: RegExpExecArray | null;
@@ -44,6 +44,10 @@ function regexParseNode(params: ReplaceInTextNodeParams): {
if (++count > 9999) {
return { nodes: [], n: 0 };
}
// Lazy init fragment
if (!fragment) {
fragment = document.createDocumentFragment();
}
const matchText = captureAdjust ? captureAdjust(match[0]) : match[0];
const matchLength = matchText.length;