3101if (existedContainerIndex >= 0) {3102const { leftPart, rightPart } = splitElement(container, [...restPath, word]);3103const newContainer = document.createDocumentFragment();31043105prevElements.splice(existedContainerIndex, 1, leftPart);3106elements.push(rightPart);31073108newContainer.append(leftPart, rightPart);3109root.replaceChild(newContainer, container);3110} else if (!elements.includes(container)) {3111elements.push(container);3112
} } elementsLineInfoList.push({ root, elements }); } return elementsLineInfoList; } /** * Get a slice of child nodes from a parent element between two specified child elements. * @param {Node} parentElement - the parent element containing the child nodes * @param {Node} fromElement - the starting child node of the slice * @param {Node} toElement - the ending child node of the slice * @returns {Node[]} - array of child nodes between fromElement and toElement (inclusive) */ function getElementChildrenSlice(parentElement, fromElement, toElement) { const childList = Array.from(parentElement.childNodes); const firstChildIndex = childList.findIndex(child => child === fromElement); const lastChildIndex = childList.findIndex(child => child === toElement); if (firstChildIndex < 0 || lastChildIndex < 0) { return []; } const minChildIndex = Math.min(firstChildIndex, lastChildIndex); const maxChildIndex = Math.max(firstChildIndex, lastChildIndex); return childList.slice(minChildIndex, maxChildIndex + 1); } /** * Wrap a slice of child nodes from a parent element between two specified child elements with a new wrapper element. * @param {Node} node - the parent element containing the child nodes * @param {Node} fromElement - the starting child node of the slice * @param {Node} toElement - the ending child node of the slice */ function wrapNodeInnerElementsByLine(node, fromElement, toElement) { const rootChildrenSlice = getElementChildrenSlice(node, fromElement, toElement); if (!rootChildrenSlice.length) { return; } const lineWrapper = t_animate__createLine(); rootChildrenSlice[0].before(lineWrapper); lineWrapper.append(...rootChildrenSlice); } const lines = t_animate__getElementLines(node); const elementsLineInfoList = splitNodeInnerElementsByLines(node, lines); elementsLineInfoList.forEach(({ root, elements }) => { const firstElement = elements.at(0); const lastElement = elements.at(-1); wrapNodeInnerElementsByLine(root, firstElement, lastElement); });}/** * Check IE browser * * @returns {Boolean} - if ie browser return true */function t_animate__checkIE() { var sAgent = window.navigator.userAgent; var Idx = sAgent.indexOf('MSIE'); var ieVersion = ''; var oldIE = false; if (Idx > 0) { ieVersion = parseInt(sAgent.substring(Idx + 5, sAgent.indexOf('.', Idx))); if (ieVersion === 8 || ieVersion === 9) { oldIE = true; } } return oldIE;}