question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Remove style attributes on default SVG template

See original GitHub issue

as mentioned here putting a style like:

style="width:0; height:0; visibility:hidden;"

is not very helpfull.

Even more when you reference the SVG externally, like:

<svg role="img" class="icon icon-pouic">
  <use xlink:href="/svg/svg-symbols.svg#icon-pouic"></use>
</svg>

It should be:

  • removed from SVG template
  • add in the doc the “hidden accessible” CSS (like in #23)

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
kencrockencommented, Mar 24, 2016

Why not use a custom template?

// custom-template.svg
<svg xmlns="http://www.w3.org/2000/svg" class="your-custom-class"><% if(defs) {%>
  <defs>
      <%= defs %>
  </defs><% } %><% _.forEach( icons, function( icon ){ %>
    <symbol id="<%= icon.id %>" viewBox="<%= icon.svg.viewBox %>"><% if (icon.title) {%>
      <title><%= icon.title %></title><% }%>
      <%= icon.svg.content %>
    </symbol><%
}); %></svg>

// In gulp task
...
.pipe($.svgSymbols({
        id:      'icon-%f',
        className:  '.icon-%f',
        title:      false,
        fontSize:   32,
        templates: [ path.join(__dirname, 'custom-template.svg'),'default-demo' ]
    })
...

see here

0reactions
Hiswecommented, Jun 9, 2018

Yep, using native modules is often a good idea 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why does TYPO3 remove values of style="" attributes during ...
-- It seems to be a longstanding Firefox Issue. Inkscape saved my SVG with inline CSS-styles, and Firefox removes these, by default. Because ......
Read more >
<style> - SVG: Scalable Vector Graphics - MDN Web Docs
This attribute defines type of the style sheet language to use as a media type string. Value type: <string>; Default value: text/css ;...
Read more >
Styling – SVG 1.1 (Second Edition) - W3C
Styling properties define how the graphics elements in the SVG content are to ... SVG content used as an exchange format (style sheet...
Read more >
remove-svg-properties - npm
Remove attributes and styles from SVGs. Latest version: 0.3.4, last published: a year ago. Start using remove-svg-properties in your project ...
Read more >
Work with SVG format in Illustrator - Adobe Support
Go to Effect > SVG Filters > Apply SVG Filter. · In the dialog box, select the effect and then select the Edit...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found