INNER CODE UNIT · TypeScript

scan

vinta/pangu.js · src/browser/index.ts:347

    const scan = (node: Node) => {
      if (node.nodeType === Node.TEXT_NODE && node.textContent) {
        if (/\s/.test(node.textContent)) {
          whitespaceBetween = true;
        }
        if (/\S/.test(node.textContent)) {
          contentBetween = true;
        }
      } else if (node instanceof Element && DomWalker.spaceLikeTags.test(node.nodeName)) {
        spaceLikeBetween = true;
      } else if (node instanceof Element && !DomWalker.isIgnoredElement(node)) {
        // Descend so wrapped whitespace counts too. Ignored islands like <code>
        // stay invisible, matching how the nodes themselves are collected
        for (let child = node.firstChild; child; child = child.nextSibling) {
          scan(child);
        }
      }
    };

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…