fix: Ensure decimal scanning waits for localization parameters to be ready before proceeding.
This commit is contained in:
parent
a3b744c2b2
commit
b819935025
@ -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()) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user