Commit 00736ca3 authored by dindigala's avatar dindigala
Browse files

refactor: renamed according to review comments

parent 86c926ca
Pipeline #218681 passed with stages
in 3 minutes and 5 seconds
......@@ -90,28 +90,29 @@ export default {
function replaceRecursive(element) {
if (!element.childNodes) return;
[...element.childNodes].forEach((c) => {
if (c === start) started = true;
if (c === end) ended = true;
[...element.childNodes].forEach((childNode) => {
if (childNode === start) started = true;
if (childNode === end) ended = true;
if (ended) return;
if (c.nodeName === 'SPAN' && c.getAttribute('data-annotation') && started) {
c.classList.add(selector);
if (childNode.nodeName === 'SPAN' && childNode.getAttribute('data-annotation') && started) {
childNode.classList.add(selector);
}
if (c.nodeName === '#text') {
if (childNode.nodeName === '#text') {
if (started) {
if (c.textContent && c.textContent.trim()) {
const s = document.createElement('span');
s.setAttribute('class', selector);
s.setAttribute('data-annotation', true);
s.innerHTML = c.textContent;
c.replaceWith(s);
if (childNode.textContent && childNode.textContent.trim()) {
const span = document.createElement('span');
span.setAttribute('class', selector);
span.setAttribute('data-annotation', true);
span.innerHTML = childNode.textContent;
childNode.replaceWith(span);
}
}
} else {
replaceRecursive(c);
replaceRecursive(childNode);
}
});
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment