Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
svg-classlist-polyfill
Advanced tools
Polyfill for classList methods (contains, add, remove, toggle) on SVG elements.
Polyfill for classList methods (contains, add, remove, toggle) on SVG elements which aren't supported on IE11 and other older browsers.
npm install svg-classlist-polyfill
import 'svg-classlist-polyfill'
That's it, polyfill will only be added if current environment doesn't already support the methods. Here is how regular usage afterwards might look like:
const icon = document.querySelector('svg.icon')
icon.classList.add('icon--blue')
icon.classList.toggle('icon--rotate')
icon.classList.remove('icon--blue')
icon.classList.contains('icon--blue') === false
Avoid setting the class with icon.className = 'icon icon--blue'
as this isn't properly supported in IE11 and will not work together with the polyfill.
There are a few test cases available in test.js
. Serve a simple website with npm test
opening this in a browser will run a few test cases quickly indicating whether the polyfill is working well.
Sourcecode partially taken from this Gist.
FAQs
Polyfill for classList methods (contains, add, remove, toggle) on SVG elements.
The npm package svg-classlist-polyfill receives a total of 1,434 weekly downloads. As such, svg-classlist-polyfill popularity was classified as popular.
We found that svg-classlist-polyfill demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
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.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.