Skip to content
This repository has been archived by the owner on Nov 16, 2021. It is now read-only.

2 fragments using the same name but from 2 different files conflicts #99

Open
Xample opened this issue Jan 15, 2019 · 8 comments
Open

Comments

@Xample
Copy link
Contributor

Xample commented Jan 15, 2019

<div [inlineSVG]="'assets/icons/thermometer/thick.svg#arrival'" [cacheSVG]="false"></div>
<div [inlineSVG]="'assets/icons/thermometer/thin.svg#arrival'" [cacheSVG]="false"></div>

Renders

image

while inverting those lines

<div [inlineSVG]="'./thin.svg#arrival'" [cacheSVG]="false"></div>
<div [inlineSVG]="'./thick.svg#arrival'" [cacheSVG]="false"></div>

gives:
image

despite the cache to be disabled, the first object will be reused by the second one

SVGs.zip

@cyphercodes96
Copy link

might it be because of the #arrival symbol?
although as i noticed the svg images have different names, they are being symbolized by the same unique chars

@Xample
Copy link
Contributor Author

Xample commented Jan 16, 2019

It could be 2 times #departure the result will be the same. I suspect some cache to use the fragment name as the key.

@arkon arkon added the bug label Mar 5, 2019
@arkon
Copy link
Owner

arkon commented Apr 7, 2019

This is indeed because of the same IDs, which this directive doesn't try to distinguish between. It'll use whichever instance of the ID shows up first on the page (since they're injected directly into the DOM).

Ideally, the symbol IDs would be different.

@arkon arkon removed the bug label Apr 7, 2019
@Xample
Copy link
Contributor Author

Xample commented Apr 7, 2019

@arkon sometimes we do not choose the name of the fragment. The namespace should be the file path (url) which will be unique per svg file, not the fragment (symbol) name

@arkon
Copy link
Owner

arkon commented Apr 7, 2019

Under the hood, it's just using the regular <use> tag, so the file path has no real relevance.

I could randomize the IDs after, but that may cause some confusion with styling.

EDIT: this is a side effect of 95c7a2f

@fatpandaria
Copy link

why setting [cacheSVG]="false" doesn't work? What's the expected behavior? I also ran into the same issue with some common ids among my svgs and wrong cache rendered.

@arkon
Copy link
Owner

arkon commented Jan 15, 2020

The cache is irrelevant to how things are rendered. Still not entirely sure how this should be solved.

@arkon
Copy link
Owner

arkon commented Jan 15, 2020

From #114:

The svg injector should support the prevention of id conflicts. It is common usage of the module to include svgs from multiple sources. The usage of svgs from different sources creates the risk of colliding ids inside the svg elements.

For example SVGInject makes all IDs inside the svg unique, before they are injected into the HTML.

I stumbled across this problem while using different svgs, which had a clipPath definition with the same id. The latter svg therefore wasn't displayed.

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

No branches or pull requests

4 participants