From c9fc53ef643b867ceb4ede78a59a60732eb1ae1b Mon Sep 17 00:00:00 2001 From: Lukas Seyfarth Date: Wed, 29 May 2024 01:12:23 +0800 Subject: [PATCH] debug --- index.js | 5 +++++ utils/selector/createLanguageSelect.js | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 57e2cd5..de7d7d9 100644 --- a/index.js +++ b/index.js @@ -122,19 +122,23 @@ function updateNode(node, language, type = "text") { // merge the falsy value into the previous string const mergedSplitted = splitted.reduce((acc, curr, index) => { if (typeof curr != 'string') { + console.log("node.textContent typeof curr != 'string'", curr) return acc; } if (typeof curr == 'string' && !curr.trim()) { + console.log("node.textContent typeof curr == 'string' && !curr.trim()", curr) acc[acc.length - 1] += curr; return acc; } return [...acc, curr]; }, []); + console.log("node.textContent mergedSplitted", mergedSplitted) const mergedOrphanString = mergedSplitted.reduce((acc, curr, index) => { const findTranslationKey = Object.entries(translatedMap).find(([key, value]) => curr.includes(value))?.[0]; + console.log("node.textContent findTranslationKey", findTranslationKey) if (!findTranslationKey) { return [ ...acc, @@ -143,6 +147,7 @@ function updateNode(node, language, type = "text") { } const findIndex = fullTextArray.findIndex(key => key.trim() == findTranslationKey.trim()); + console.log("node.textContent findIndex", findIndex) if (findIndex == -1) { return [ ...acc, diff --git a/utils/selector/createLanguageSelect.js b/utils/selector/createLanguageSelect.js index 54401d5..a639305 100644 --- a/utils/selector/createLanguageSelect.js +++ b/utils/selector/createLanguageSelect.js @@ -198,7 +198,6 @@ async function createLanguageSelect(apiKey, optsArgs = {}) { } } - autoPosition(); weploySwitcher.onclick = autoPosition if (languages.length < 2) { @@ -279,6 +278,7 @@ async function createLanguageSelect(apiKey, optsArgs = {}) { }); if (!initializedSelectorByUser) weploySwitcher.appendChild(details); + autoPosition(); } }); }