`var text = (node.nodeName === 'BR') ? '\n' : node.textContent;` better.