Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

decorateIcons() accidentally hides polygons from SVG elements #191

Open
dicagno opened this issue Mar 16, 2023 · 2 comments
Open

decorateIcons() accidentally hides polygons from SVG elements #191

dicagno opened this issue Mar 16, 2023 · 2 comments

Comments

@dicagno
Copy link

dicagno commented Mar 16, 2023

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

  • The PR for this fix removes width and height attributes only from the root element.
  • Usage of DOMParser where possible (as mentioned)
@ramboz
Copy link
Collaborator

ramboz commented Mar 16, 2023

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
Copy link

bstopp commented Nov 1, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants