ampproject / amp-toolbox-php

AMP Optimizer PHP library
Apache License 2.0
73 stars 25 forks source link

`SelfClosingSVGElements` document filter erroneously self-closes `g` tags #512

Closed westonruter closed 2 years ago

westonruter commented 2 years ago

As reported in a AMP plugin support forum topic, given this input HTML:

<svg>
  <g id="ok">
    <path/>
  </g>
</svg>

The output is:

<svg>
  <g id="ok"/>
    <path/>
</svg>

I was able to prevent this from happening by commenting out Tag::G from SelfClosingSVGElements::SELF_CLOSING_TAGS:

https://github.com/ampproject/amp-toolbox-php/blob/4cecbc5953823f15c2f9ea22ec3ee947040c1547/src/Dom/Document/Filter/SelfClosingSVGElements.php#L21-L25