If that's your worry can this solve it: `(node.textContent || "").trim()`.