Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IE11 innerHTML strange behaviour

.childNodes is a generated array (...well NodeList) that is filled with ELEMENT_NODE but may also be filled with: ATTRIBUTE_NODE, TEXT_NODE, CDATA_SECTION_NODE, ENTITY_REFERENCE_NODE, ENTITY_NODE, PROCESSING_INSTRUCTION_NODE, COMMENT_NODE, DOCUMENT_NODE, DOCUMENT_TYPE_NODE, DOCUMENT_FRAGMENT_NODE, NOTATION_NODE, ...

You probably want only nodes from the type: ELEMENT_NODE (div and such..) and maybe also TEXT_NODE.

Use a simple loop to keep just those nodes with .nodeType === Element.ELEMENT_NODE (or just compare it to its enum which is 1).

You can also just use the much more simpler alternative of .children.