fix: Ensure decimal scanning waits for localization parameters to be ready before proceeding.

This commit is contained in:
Suherdy Yacob 2026-02-05 17:43:31 +07:00
parent a3b744c2b2
commit b819935025

View File

@ -74,6 +74,19 @@ function processNode(textNode) {
function scanDocument() { function scanDocument() {
try {
// Check if localization is ready by accessing the property
// This will throw if parameters are not ready
const _ = localization.decimalPoint;
} catch (e) {
// If not ready, retry in 200ms
if (timeout) cancelAnimationFrame(timeout);
timeout = setTimeout(() => {
requestAnimationFrame(scanDocument);
}, 200);
return;
}
const walker = document.createTreeWalker(document.body, NodeFilter.SHOW_TEXT, null); const walker = document.createTreeWalker(document.body, NodeFilter.SHOW_TEXT, null);
const nodesToProcess = []; const nodesToProcess = [];
while (walker.nextNode()) { while (walker.nextNode()) {