xmldom / xmldom

A pure JavaScript W3C standard-based (XML DOM Level 2 Core) `DOMParser` and `XMLSerializer` module.
MIT License
361 stars 88 forks source link

normalize() should drop empty text nodes #411

Open marrus-sh opened 2 years ago

marrus-sh commented 2 years ago

DOM Level 2 states :—

Puts all Text nodes in the full depth of the sub-tree underneath this Node, including attribute nodes, into a "normal" form where only structure (e.g., elements, comments, processing instructions, CDATA sections, and entity references) separates Text nodes, i.e., there are neither adjacent Text nodes nor empty Text nodes.

https://www.w3.org/TR/DOM-Level-2-Core/#core-ID-normalize

Right now in xmldom, empty text nodes are not removed.

karfau commented 2 years ago

Thx for pointing it out. I think it should not be to tricky to implement, including tests.