shrpne / vue-inline-svg

Dynamically loads an SVG source and inline <svg> element so you can manipulate the style of it
MIT License
175 stars 21 forks source link

Add "title" prop to set/overwrite SVG title #18

Closed mjr9804 closed 4 years ago

mjr9804 commented 4 years ago

Adds a title prop to allow setting the content of the SVG's <title> element. If the SVG already has a title, it will be overwritten with the value of the prop. Otherwise, a <title> is created and appended to the SVG.

Fixes #3

shrpne commented 4 years ago

Thank you for the PR! I will try to take a look at the weekend

mjr9804 commented 4 years ago

I ran into one issue with this change. Since the title is set when the SVG is downloaded, you can't use the same image in 2 places with different titles. The first title that is set will always be used since the image is (nicely) only downloaded once and then cached.

I'll look at moving the setTitle to a more appropriate place when I have some free time.

mjr9804 commented 4 years ago

Updated with a better diff that sets the title each time the image is used (not just when the SVG is downloaded)

shrpne commented 4 years ago

Nice! I hope I will have some free time this week to review and publish it.

shrpne commented 4 years ago

Released under v2.0.0. Thank you again!