Socket
Socket
Sign inDemoInstall

cssstyle

Package Overview
Dependencies
1
Maintainers
3
Versions
51
Alerts
File Explorer

Advanced tools

Install Socket

Protect your apps from supply chain attacks

Install

cssstyle

CSSStyleDeclaration Object Model implementation

    4.0.1latest
    GitHub
    npm

Version published
Maintainers
3
Weekly downloads
20,758,163
increased by3.21%

Weekly downloads

Package description

What is cssstyle?

The cssstyle npm package is designed to mimic the CSSStyleDeclaration interface provided by browsers, allowing for the manipulation of CSS properties of elements in a JavaScript environment outside of the browser, such as in server-side applications or testing environments. It provides a way to parse, manipulate, and stringify CSS properties programmatically.

What are cssstyle's main functionalities?

Parsing CSS properties

This feature allows the parsing of CSS text into individual properties that can be accessed and manipulated through the CSSStyleDeclaration object.

{"var CSSStyleDeclaration = require('cssstyle');
var css = new CSSStyleDeclaration();
css.cssText = 'color: blue; background-color: white;';
console.log(css.color); // 'blue'"}

Manipulating CSS properties

This feature enables the setting and getting of individual CSS properties using methods like setProperty and getPropertyValue.

{"var CSSStyleDeclaration = require('cssstyle');
var css = new CSSStyleDeclaration();
css.setProperty('color', 'red');
console.log(css.cssText); // 'color: red;'"}

Stringifying CSS properties

This feature allows the CSSStyleDeclaration object to be converted back into a string representation of the CSS, which can be used in HTML or other contexts.

{"var CSSStyleDeclaration = require('cssstyle');
var css = new CSSStyleDeclaration();
css.setProperty('color', 'red');
console.log(css.cssText); // 'color: red;'"}

Other packages similar to cssstyle

Readme

Source

CSSStyleDeclaration

A Node JS implementation of the CSS Object Model CSSStyleDeclaration interface.

NpmVersion Build Status codecov


Background

This package is an extension of the CSSStyleDeclaration class in Nikita Vasilyev's CSSOM with added support for CSS 2 & 3 properties. The primary use case is for testing browser code in a Node environment.

It was originally created by Chad Walker, it is now maintained by the jsdom community.

Bug reports and pull requests are welcome.

Keywords

FAQs

Last updated on 28 Dec 2023

Did you know?

Socket installs a GitHub app to automatically flag issues on every pull request and report the health of your dependencies. Find out what is inside your node modules and prevent malicious activity before you update the dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc