adobe / aem-boilerplate

Use this repository template for new AEM projects.
https://main--aem-boilerplate--adobe.hlx.page
Apache License 2.0
111 stars 283 forks source link

decorateIcons() accidentally hides polygons from SVG elements #191

Open dicagno opened 1 year ago

dicagno commented 1 year ago

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

ramboz commented 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)

bstopp commented 8 months ago

I think this is no longer an issue given the change icons are handled.