fix: Identify empty text in advance
This commit is contained in:
@@ -976,7 +976,8 @@ export class Translator {
|
|||||||
if (node.nodeType === Node.ELEMENT_NODE) {
|
if (node.nodeType === Node.ELEMENT_NODE) {
|
||||||
if (
|
if (
|
||||||
Translator.TAGS.REPLACE.has(node.tagName) ||
|
Translator.TAGS.REPLACE.has(node.tagName) ||
|
||||||
node.matches(this.#rule.keepSelector)
|
node.matches(this.#rule.keepSelector) ||
|
||||||
|
!node.textContent.trim()
|
||||||
) {
|
) {
|
||||||
if (node.tagName === "IMG" || node.tagName === "SVG") {
|
if (node.tagName === "IMG" || node.tagName === "SVG") {
|
||||||
node.style.width = `${node.offsetWidth}px`;
|
node.style.width = `${node.offsetWidth}px`;
|
||||||
@@ -991,10 +992,6 @@ export class Translator {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (Translator.TAGS.WARP.has(node.tagName)) {
|
if (Translator.TAGS.WARP.has(node.tagName)) {
|
||||||
if (this.#isInvalidText(innerContent)) {
|
|
||||||
return pushReplace(node.outerHTML);
|
|
||||||
}
|
|
||||||
|
|
||||||
wrapCounter++;
|
wrapCounter++;
|
||||||
const startPlaceholder = `<${Translator.PLACEHOLDER.tagName}${wrapCounter}>`;
|
const startPlaceholder = `<${Translator.PLACEHOLDER.tagName}${wrapCounter}>`;
|
||||||
const endPlaceholder = `</${Translator.PLACEHOLDER.tagName}${wrapCounter}>`;
|
const endPlaceholder = `</${Translator.PLACEHOLDER.tagName}${wrapCounter}>`;
|
||||||
|
|||||||
Reference in New Issue
Block a user