Skip to content

cdoublev/css

Repository files navigation

CSS

JavaScript implementation of CSS.

Usage

const { cssom, install } = require('@cdoublev/css')

/**
 * install() expects a window-like global object (default: globalThis) with
 * document, Array, Object, Number, String, TypeError.
 */
install(/*myGlobalObject*/)

// Create a CSSStyleSheet
const styleSheet = new /*myGlobalObject.*/CSSStyleSheet()

// Create a CSSStyleSheet or CSSStyleDeclaration wrapper
const stylesheet = cssom.CSSStyleSheet.create(myGlobalObject, undefined, privateProperties)
const style = cssom.CSSStyleDeclaration.create(myGlobalObject, undefined, privateProperties)

The webidl2js wrappers are intended to implement:

To sum up, they mostly exist to create CSSStyleSheet and CSSStyleDeclaration. Below are the properties defined in the CSSOM specification and their associated property read in privateProperties:

CSSStyleSheet

  • CSS rules: rules (String or ReadableStream)
  • alternate flag: alternate (Boolean, optional, default: false)
  • disabled flag: disabled (Boolean, optional, default: false)
  • location: location (String, optional, default: null)
  • media: media (String or MediaList)
  • origin-clean flag: originClean (Boolean)
  • owner CSS rule: ownerRule (CSSRule, optional, default: null)
  • owner node: ownerNode (HTMLElement)
  • parent CSS style sheet: parentStyleSheet (CSSStyleSheet, optional, default: null)
  • title: title (String, optional, default: '')

CSSStyleDeclaration

  • computed flag: computed (Boolean, optional, default: false)
  • declarations: declarations ([Declaration], optional, default: [])
  • owner node: ownerNode (HTMLElement, optional, default: null)
  • parent CSS rule: parentRule (CSSRule, optional, default: null)

Declaration must be a plain object with the following properties:

  • name: String
  • value: String
  • important: Boolean (optional, default: false)

About

JavaScript implementation of CSS object models.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published