0.5.0 • Published 3 years ago

cssom v0.5.0

Weekly downloads
19,243,918
License
MIT
Repository
github
Last release
3 years ago

CSSOM

CSSOM.js is a CSS parser written in pure JavaScript. It is also a partial implementation of CSS Object Model.

CSSOM.parse("body {color: black}")
-> {
  cssRules: [
    {
      selectorText: "body",
      style: {
        0: "color",
        color: "black",
        length: 1
      }
    }
  ]
}

Parser demo

Works well in Google Chrome 6+, Safari 5+, Firefox 3.6+, Opera 10.63+. Doesn't work in IE < 9 because of unsupported getters/setters.

To use CSSOM.js in the browser you might want to build a one-file version that exposes a single CSSOM global variable:

➤ git clone https://github.com/NV/CSSOM.git
➤ cd CSSOM
➤ node build.js
build/CSSOM.js is done

To use it with Node.js or any other CommonJS loader:

➤ npm install cssom

Don’t use it if...

You parse CSS to mungle, minify or reformat code like this:

div {
  background: gray;
  background: linear-gradient(to bottom, white 0%, black 100%);
}

This pattern is often used to give browsers that don’t understand linear gradients a fallback solution (e.g. gray color in the example). In CSSOM, background: gray gets overwritten. It does NOT get preserved.

If you do CSS mungling, minification, or image inlining, considere using one of the following:

Tests

To run tests locally:

➤ git submodule init
➤ git submodule update

Who uses CSSOM.js

archetype-libraryreact-native-bluetooth2killi8n-react-native-fast-imageticket-jsdomspecify-importsbabel-specify-imports@icanpm/api-masterpaperbits-demojsdom-exreact-native-template-rfbaseairscanairscan-examplereact-native-esc-pos-sahaab@borisovart/atol-kkt-modulejuice-enhanceddeneme323112@ntt_app/react-native-custom-notificationreact-native-covid-sdkgql_din_modbitgetjsdom-fork@olivervorasai/sliderreact-native-printer-brothersisv-lynx-devwilscannerjsdom__no_corsstretch-rollup@mink-opn/build-tokensreact-native-slider-kfsvelte-slime@twbs/svg-spriteplginexpand-react-bridgesklif-ui-kitsklif-api@everything-registry/sub-chunk-1421p149-table@pmadhur/jsdomsklif-uidate-library-aadom-extractordataormdiscord.js-bycondidi-postpackager-fontmindiscordjs-con-selfnode-jsdomunonativedxpnodetilesunudrift-npmdrive.jsdskcorenewobjectjs-opmnka-gantt-task-reactnumhandleroctemplateomnismodi@simstudio/htmldiffcustome-package-amincustom-roulettecs188-spring2022css-slap-chopcss-slice-imgcss-slice-imgscss-rulescsstransformcssspriterdeclassifycsskeepercss-summarycss-spritescss-findcss-fixdfeuk-frontenddfeuk-frontend-manualdigital-keyboard-demos@nyanator/chrome-ext-utils@nojaja/htmlcompilerreact-microphone-recorder1react-native-badge-controlreact-native-biometric-authenticate@poscredit/plugin-chart-borisreact-native-android-scoped-storage@object-studio/react-native-web@percent/percent-api-hooks@phong95/react-native-multiple-image-picker@picaro/colorhelper@sentry-internal/rrdom-nodejs@nosnibor89/cdk-static-website-constructgulp-viewport-unitsreact-native-contact-listreact-native-dsphoto-modulereact-native-cplusreact-native-create-video-thumbnailreact-native-bubble-chartreact-native-is7react-native-jsi-device-inforeact-native-kakao-maps@smartpartner/postdirekt-autocomplete
0.5.0

3 years ago

0.4.4

4 years ago

0.4.3

4 years ago

0.4.2

4 years ago

0.4.1

5 years ago

0.4.0

5 years ago

0.3.8

5 years ago

0.3.7

5 years ago

0.3.6

5 years ago

0.3.5

5 years ago

0.3.4

6 years ago

0.3.3

6 years ago

0.3.2

7 years ago

0.3.1

8 years ago

0.3.0

10 years ago

0.2.5

12 years ago

0.2.4

12 years ago

0.2.3

12 years ago

0.2.2

12 years ago

0.2.1

12 years ago

0.2.0

13 years ago