It looks like the value ```8``` has a corresponding named constant ```COMMENT_NODE``` ( see http://www.w3schools.com/jsref/prop_node_nodetype.asp ). Could you check if the constant also works correctly in your use-case?