Fix textContent for nodes that do not have children

Fixes #483.