Recursively collects text content from a DOM subtree, descending into nested
shadow roots. Standard Node.textContent does not pierce shadow DOM boundaries,
which means resolved text inside child custom-elements (such as <ufm-content-name>
whose async result lives in its own shadow root) is invisible to it. This helper
walks the tree and reads through.
Parameters
root: Element|ShadowRoot|null|undefined
the element or shadow root to traverse. If an Element with a shadow root is provided, the shadow root is traversed in preference to the light DOM children.
Returns string
the concatenated text content of every descendant text node, skipping empty fragments.
Recursively collects text content from a DOM subtree, descending into nested shadow roots. Standard
Node.textContentdoes not pierce shadow DOM boundaries, which means resolved text inside child custom-elements (such as<ufm-content-name>whose async result lives in its own shadow root) is invisible to it. This helper walks the tree and reads through.