INNER CODE UNIT · TypeScript
lastTextNode
vinta/pangu.js · src/browser/index.ts:290
const lastTextNode = textNodes.at(-1);
if (!firstTextNode || !lastTextNode) {
return textNodes;
}
const previousTextNode = DomWalker.findAdjacentTextNode(firstTextNode, 'previous');
const nextTextNode = DomWalker.findAdjacentTextNode(lastTextNode, 'next');
return [...(previousTextNode ? [previousTextNode] : []), ...textNodes, ...(nextTextNode ? [nextTextNode] : [])];
}
private hasSpacedTextInSubtree(node: Node) {
if (node instanceof Text) {
return this.lastWrittenData.has(node);
}
const walker = document.createTreeWalker(node, NodeFilter.SHOW_TEXT);
while (walker.nextNode()) {
if (this.lastWrittenData.has(walker.currentNode as Text)) {
return true;
}