Reverted last two commits, as escaping is not required for document.createTextNode(). However HTML escaping is required after reading from text node (in toString method).