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

Duplicate id in svg #45

Closed
faniry-abl opened this issue Apr 8, 2021 · 1 comment
Closed

Duplicate id in svg #45

faniry-abl opened this issue Apr 8, 2021 · 1 comment

Comments

@faniry-abl
Copy link

faniry-abl commented Apr 8, 2021

I render multiple avatars in a custom avatar editor and when some of them are removed from the DOM, then the remaining svg does not render well anymore on Safari only.

image-20210406-120920

I have tried the following code (shivam1410/fangpenlin-avataaars-generator-angular#5) but it did not work, on the contrary, it broke the svg:

var svgSel = '#root > div > div > main > main > div > div > div.avatar-main-preview > svg';
document.querySelectorAll(svgSel + ' [mask^="url("]').forEach(node => {
    var attributMask = node.getAttribute("mask");
    node.setAttribute("mask",  + attributMask.replace('url(', 'url(' + location.href));
});
document.querySelectorAll(svgSel + ' [filter^="url("]').forEach(node => {
    var attributFilter = node.getAttribute("filter");
    node.setAttribute("filter",  + attributFilter.replace('url(', 'url(' + location.href));
});
document.querySelectorAll(svgSel + ' [fill^="url("]').forEach(node => {
    var attributFill = node.getAttribute("fill");
    node.setAttribute("fill",  + attributFill.replace('url(', 'url(' + location.href));
});

Could this be because:

My confusion here is:

  • should we use a class instead of an id
  • or have completely 2 different names for the 2 ids that are conflicting here?

Thank you!

@faniry-abl
Copy link
Author

This issue is resolved when instead of removing my avatars from the DOM, I put them away from the viewport and set their opacity to 0.

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

No branches or pull requests

1 participant