svgo
                                
                                 svgo copied to clipboard
                                
                                    svgo copied to clipboard
                            
                            
                            
                        Incorrect parsing of html tags within `foreignObject` tags
Describe the bug Empty html tags are transformed into self-closing tags which breaks expected image. Required whitespaces from text nodes are removed.
To Reproduce
import SVGO from "svgo"
const svg = `
<svg xmlns="http://www.w3.org/2000/svg">
  <foreignObject x="0" y="0" width="100%" height="100%">
    <div xmlns="http://www.w3.org/1999/xhtml">
      Lorem <span>ipsum</span> dolor
    </div>
    <div class="empty-div"></div>
  </foreignObject>
</svg>`
const {data} = await SVGO.optimize(svg, {multipass:true})
console.log(data)
Expected behavior
+<svg xmlns="http://www.w3.org/2000/svg"><foreignObject x="0" y="0" width="100%" height="100%"><div xmlns="http://www.w3.org/1999/xhtml">Lorem <span>ipsum</span> dolor</div><div class="empty-div"></div></foreignObject></svg>
-<svg xmlns="http://www.w3.org/2000/svg"><foreignObject x="0" y="0" width="100%" height="100%"><div xmlns="http://www.w3.org/1999/xhtml">Lorem<span>ipsum</span>dolor</div><div class="empty-div"/></foreignObject></svg>
- Empty <div>tag should not be transformed into self closing tags (breaks html interpretation by creating "unclosed" tags)
- Spaces within html text nodes are not preserved (note that xml:space="preserve"or using change nothing)
Desktop (please complete the following information):
- SVGO Version: 2.3.0
- NodeJs Version: 14.9.0
- OS: Windows
Additional context Relates to #1421, but add more insight about troubleshooting and reproduction Updated https://github.com/lowlighter/metrics/issues/172#issue-822378888 to display original and optimized image
bump
bump....