Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

sheetjs

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sheetjs

Easily create and manipulate CSSStyleDeclarations with javascript.

  • 1.0.9
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3.2K
decreased by-27.81%
Maintainers
1
Weekly downloads
 
Created
Source

SheetJS

Easily create and manipulate CSSStyleDeclarations with javascript:

var s = require('sheetjs').createStyle;

// 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.

jQuery .css() vs SheetJS

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

Demo

http://codepen.io/jshanson7/pen/Jdpdga?editors=001

Installation

npm install sheetjs

Then reference either dist/sheet.js or dist/sheet.min.js in your html, or require('sheetjs') with Browserify. If a module environment is not detected, sheetjs will be attached to window.

API

var sheetjs = require('sheetjs');

// createStyle - get CSSStyleDeclaration for selector (or create if it doesn't exist)
var styleDeclaration = sheetjs.createStyle('.my-el');
styleDeclaration.backgroundColor = 'green';

// deleteStyle - delete CSSStyleDeclaration for selector
sheetjs.deleteStyle('.my-el'); // 'backgroundColor' is no longer green

// getStyle - get existing CSSStyleDeclaration for selector
var styleDeclaration2 = sheetjs.getStyle('.doesnt-exist');
styleDeclaration2 === undefined; // true

// disable - disables the stylesheet associated with sheetjs (and all generated styles)
sheetjs.disable();

// enable - enables the stylesheet associated with sheetjs (and all generated styles)
sheetjs.enable();

Contributing

Clone repo, cd into it.

npm install
npm install -g gulp

Development

gulp watch

Production

gulp bundle --produciton

License

MIT

Keywords

FAQs

Package last updated on 06 Jul 2015

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc