-
Notifications
You must be signed in to change notification settings - Fork 88
Should support being provided with a SVG as a string #75
Comments
Maybe proving an svg like this would keep the API clean:
|
I'm not sure if it's really practical as a library user to provide data URIs. That said, I'm not entirely sure why you would readily have an SVG as a string either. It'd make more sense to me if you had the element itself, but @espeandr can chime in. |
I did express the motivation behind this issue in the original issue's body, but I'll try to rephrase: This directive handles fetching of a SVG by using the |
If that's the case, wouldn't it make more sense to be able to specify something to use for fetching the SVG, which the directive can use in place of the default |
I see your point, but wouldn't this service that replaces In my case, such a class would retry failing requests, as well as alerting users that a issue has occurred by displaying a toast through another dependent service. However, I might not want this "retry and alert" mechanism for all SVGs I insert using this directive. To solve this, one could provide the directive with such a service as a input instead, or have a flag deciding whether to use the default "SVGFetcher ( I might have misunderstood your suggestion, or there might be a better way to do what you suggested @arkon, but based on what I laid out above, I still think allowing users to provide the directive with a SVG as a string directly is the simplest and most flexible way to give consumers of the directive control of the fetching of a SVG themselves. |
From my implementation point of view, it'd just be a matter of providing the user a way of passing in an implementer of a Maybe it'd be possible to provide both the current |
I have a case where the svg definition is inside a database (CLOB). I would simply take this string and render it inside my component (caches are working fine). It would be a nice feature! |
In my case this is usefull because I need to load a few hundred svgs and doing a single HTTP Request for them is not really nice. Fetching them all at the same time in a json document would be much nicer. |
I'm currently really struggling with finding a good svg injector, which supports an svg string. Is there currently a workaround for using a string based svg resource with |
It is also something I would find useful as i'm storing some SVGs inside indexedDB for offline use. The SVGFetcher implementation would be inconvenient in my case because I have more than one type of svg and they come from different sources. |
I'm submitting a...
Current behavior
Currently the directive only support beeing provided a SVG through a URL.
Wanted behaviour
I would like to be able to pass the directive a SVG as a string, like so:
What is the motivation / use case for changing the behavior?
By beeing able to provide SVG as a string, developers can handle the fetching of the SVG themselves. My concrete need is to be able to implement a retry mechanism on the fetching of the SVG.
The text was updated successfully, but these errors were encountered: