MCPcopy Create free account
hub / github.com/Alphanimble/htmlstream / findLastTextNode

Function findLastTextNode

src/patch-streaming-html.ts:180–193  ·  view source on GitHub ↗

Deepest last text node under `root` (matches insertAdjacentText tail).

(root: Node)

Source from the content-addressed store, hash-verified

178
179/** Deepest last text node under `root` (matches insertAdjacentText tail). */
180function findLastTextNode(root: Node): Text | null {
181 if (root.nodeType === Node.TEXT_NODE) {
182 const text = root as Text;
183 return text.data.length > 0 ? text : null;
184 }
185
186 for (let i = root.childNodes.length - 1; i >= 0; i--) {
187 const found = findLastTextNode(root.childNodes[i]!);
188 if (found) {
189 return found;
190 }
191 }
192 return null;
193}
194
195function collapseRangeAtTextEnd(range: Range, text: Text): void {
196 range.setStart(text, text.data.length);

Callers 1

resolveStreamCaretRangeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected