Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Easily create and manipulate CSSStyleDeclarations
with javascript:
import { StyleSheet } from 'sheetjs';
// or
const { StyleSheet } = window.sheetjs;
const styleSheet = new StyleSheet();
const s = styleSheet.stylesForSelector;
// changes background color for all current and future matching elements
s('#content .my-selector').backgroundColor = 'green';
Good for when you have a dynamic number of elements that need dynamic styling.
Imagine a web page with 1000 elements with class my-el
, and you want to change their background-color
to green
.
Using jQuery:
// changes background color for all current matching elements
$('.my-el').css('background-color', 'green');
// took ~10ms
// new elements will not be green
Using SheetJS:
// changes background color for all current and future matching elements
s('.my-el').backgroundColor = 'green';
// took <1ms
// new elements will be green
http://codepen.io/jshanson7/pen/Jdpdga?editors=001
npm install sheetjs
Then reference either dist/sheet.js
or dist/sheet.min.js
in your html, or import 'sheetjs'
. If a module environment is not detected, sheetjs
will be exported to window.sheetjs
.
import StyleSheet from 'sheetjs/StyleSheet';
const styleSheet = new StyleSheet({
'html, body': {
margin: 0,
padding: 0
},
'.my-el': {
backgroundColor: 'green'
},
'.my-el:hover': {
backgroundColor: 'blue'
}
});
import StyleSheet from 'sheetjs/StyleSheet';
const styleSheet = new StyleSheet();
const s = styleSheet.stylesForSelector;
// stylesForSelector - get CSSStyleDeclaration for selector (or create if it doesn't exist)
const styleDeclaration = styleSheet.stylesForSelector('.my-el');
styleDeclaration.backgroundColor = 'green';
// deleteStylesForSelector - delete CSSStyleDeclaration for selector
styleSheet.deleteStylesForSelector('.my-el'); // 'backgroundColor' is no longer green
// getStylesForSelector - get existing CSSStyleDeclaration for selector
const styleDeclaration2 = styleSheet.getStylesForSelector('.doesnt-exist');
styleDeclaration2 === undefined; // true
// disable - disables the stylesheet (and all generated styles)
styleSheet.disable();
// enable - enables the stylesheet (and all generated styles)
styleSheet.enable();
Clone repo, cd into it.
npm install && npm start
npm run build
Run the tests on your browser here.
npm test && npm run test-browser
MIT
FAQs
Placeholder package for SheetJS
The npm package sheetjs receives a total of 2,507 weekly downloads. As such, sheetjs popularity was classified as popular.
We found that sheetjs demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.