Skip to content

Commit

Permalink
wrap plain textnode in span
Browse files Browse the repository at this point in the history
  • Loading branch information
jemikanegara committed Jun 24, 2024
1 parent b787494 commit 16a6fbe
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions utils/translation/extractTextNodes.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,9 +233,9 @@ function extractTextNodes(node, textNodes) {
const textNodesForContextWithCurrentNode = [...leftTextNodes, singleTextNode, ...rightTextNodes];

const context = textNodesForContextWithCurrentNode.reduce((acc, textNode) => {
// if has sibling, then dont inject tag name
// if has sibling, then inject span (for splitting purpose on backend)
if (textNode.parentNode.childNodes.length > 1) {
return `${acc} ${textNode.textContent}`;
return `${acc} <span>${textNode.textContent}</span>`;
} else {
return `${acc} <${textNode.parentNode.tagName.toLowerCase()}>${textNode.textContent}</${textNode.parentNode.tagName.toLowerCase()}>`;
}
Expand Down

0 comments on commit 16a6fbe

Please sign in to comment.