iconfu / svg-inject

A tiny, intuitive, robust, caching solution for injecting SVG files inline into the DOM.
MIT License
800 stars 85 forks source link

'title' attribute not handled properly if namespaced title exists #23

Closed waruyama closed 6 years ago

waruyama commented 6 years ago

Currently, if a title attribute is specified in the <img> element and the injected SVG already has a namespaced title element (for example <svg:title>, a new title element is created and inserted before the existing namespaced `´ element. </p> <p>Instead the existing namespaced title element should be used and the content changed to the value of the <code>img</code>'s title attribute.</p> </div> </div> <div class="comment"> <div class="user"> <a rel="noreferrer nofollow" target="_blank" href="https://github.com/waruyama"><img src="https://avatars.githubusercontent.com/u/43434568?v=4" />waruyama</a> commented <strong> 6 years ago</strong> </div> <div class="markdown-body"> <p>Simple fix by using <code>localName</code> instead of <code>tagName</code> when checking for title element. Also, if a title element already exists, we should reuse it instead of replacing it with a new element.</p> </div> </div> <div class="comment"> <div class="user"> <a rel="noreferrer nofollow" target="_blank" href="https://github.com/iconfu"><img src="https://avatars.githubusercontent.com/u/12932341?v=4" />iconfu</a> commented <strong> 6 years ago</strong> </div> <div class="markdown-body"> <p>just released Version 1.2.0 which fixes this issue</p> </div> </div> <div class="page-bar-simple"> </div> <div class="footer"> <ul class="body"> <li>© <script> document.write(new Date().getFullYear()) </script> Githubissues.</li> <li>Githubissues is a development platform for aggregating issues.</li> </ul> </div> <script src="https://cdn.jsdelivr.net/npm/jquery@3.5.1/dist/jquery.min.js"></script> <script src="/githubissues/assets/js.js"></script> <script src="/githubissues/assets/markdown.js"></script> <script src="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.4.0/build/highlight.min.js"></script> <script src="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.4.0/build/languages/go.min.js"></script> <script> hljs.highlightAll(); </script> </body> </html>