Open dicagno opened 1 year ago
Good point. That regexp is too generic, indeed. The idea was just to strip out the ones on the initial svg tag so that you can essentially adjust the viewport of the SVG via CSS if needed (i.e. to align several icon sizes on a page when the original icons have different sizes)
I think this is no longer an issue given the change icons are handled.
Expected Behaviour
SVG images, including vector logos, displaying correctly all the elements (e.g. rects)
Actual Behaviour
some SVG images are shown with missing rects or polygons
Root cause (identified)
The following lines are stripping width and height attributes from all the vector elements in a svg element: https://github.com/adobe/helix-project-boilerplate/blob/main/scripts/lib-franklin.js#LL161-L162
In addition, regexp are used to strip or replace attributes and their values: a safer approach (proposed in the linked PR) would be to use an instance of
DOMParser
.Proposed solution