New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

svg-inject

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

svg-inject

Replace an `` element with an inline SVG.

latest
Source
npmnpm
Version
0.1.0
Version published
Maintainers
1
Created
Source

svg-inject experimental

Replace an <img> element with an inline SVG. This way you can still earn the benefits of not inlining every occurence of an SVG, but still style their contents using CSS selectors. This makes adding hover states and the like much more straightforward :)

Usage

NPM

inject(element, [callback])

Replace the <img> element with an SVG, calling callback(err, svg) when complete.

// Replaces all existing SVG images on the DOM with inline SVGs:
var inject = require('svg-inject')
var svgs = document.querySelector('img[src$=".svg"]')

for (var i = 0; i < svgs.length; i++) {
  inject(svgs[i], function(err, svg) {
    if (err) throw err
    // do additional things with `svg` here if you like.
  })
}

See Also

License

MIT. See LICENSE.md for details.

Keywords

svg

FAQs

Package last updated on 19 Apr 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts