• Stars
    star
    733
  • Rank 61,835 (Top 2 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created about 14 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Unmaintained! ⚠️ CSS Object Model implemented in pure JavaScript. Also, a CSS parser.

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

Why is this not maintained?

  1. I no longer use it in my projects
  2. Even though cssom npm package has 26 million weekly downloads (as of April 17, 2023), I haven't made a dollar from my work.

If you want specific issues to be resolved, you can hire me for $100 per hour (which is 1/2 of my normal rate).

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

More Repositories

1

chrome-devtools-autosave

Auto-saving CSS and JavaScript changes from the Chrome Developer Tools
JavaScript
1,052
star
2

flying-focus

UI concept
JavaScript
437
star
3

objectDiff.js

Compares JavaScript objects
JavaScript
259
star
4

chrome-devtools-autosave-server

Simple Node.js server for chrome-devtools-autosave
JavaScript
157
star
5

placeholder.js

Brings HTML5 placeholder attribute into all modern browsers (not maintained any more)
JavaScript
116
star
6

captureCalls.js

captureCalls('document.getElementById') to show a stack trace for document.getElementById on its every call
JavaScript
112
star
7

console.js

Crossbrowser Firebug console API. Improves Opera Dragonfly and IE developer tools.
JavaScript
74
star
8

nice-alert.js

Makes alert box suck less
JavaScript
38
star
9

setInterval-sniffer

Keep tabs on your uncleared intervals. Hunt down lags and memory leaks.
JavaScript
38
star
10

github-live-preview

Live Markdown preview for commit’s comments, markdown files, and inbox messages
JavaScript
37
star
11

jsDump

Fork of jsDump by Ariel Flesler
JavaScript
31
star
12

focus-snail

Leaves a trail from the previously focused element.
JavaScript
25
star
13

faviconize-google.js

Adds favicons to each link offered by Google search results.
JavaScript
25
star
14

JSCSSP

CommonJS module of JavaScript CSS Parser written by Daniel Glazman
JavaScript
21
star
15

jquery-regexp-classes

$(elem).removeClass(regExp) and $(elem).hasClass(regExp)
JavaScript
19
star
16

jsonpwrapper.com

Everything to JSONP converter. Gateway for crossdomain requests.
JavaScript
16
star
17

textarea-backup.js

Retains text entered into textareas
JavaScript
14
star
18

chrome-o-tile

Google Chrome extension. Tiling windows manager.
JavaScript
12
star
19

notes

Notes web app built for 10K Apart in 2010
JavaScript
12
star
20

js-preprocessor

Stupidly simple command line tool for squashing JS and CSS files. Used mostly for building UserJS
Ruby
11
star
21

css_auto-reload

Edit CSS, save, see result. No need to reload a whole page.
JavaScript
11
star
22

box-slider

JavaScript carousel plug-in that uses native scrolling. Pure JS and jQuery versions.
JavaScript
10
star
23

color-blender

Color Blender for 10K competition.
JavaScript
8
star
24

dom-dom-dom.com

My idea for Node.js Knockout
JavaScript
8
star
25

show-password-on-focus.js

Show password when focus on password field
JavaScript
8
star
26

focus-hug

Focus outline transition
JavaScript
8
star
27

google-diff-match-patch

A fork that diffs arrays rather than strings
JavaScript
6
star
28

typun

Type trainer
JavaScript
5
star
29

ext.js

JavaScript extensions and utilities for node.js (and others) -- supports CommonJS modules and optional prototype extensions
JavaScript
5
star
30

jasmine-html-reporter

Nice looking HTML-reporter for Jasmine BDD
JavaScript
4
star
31

focus-zoom

Zoom newly focused element for a fraction of a second.
JavaScript
4
star
32

web-inspector

My patches to WebKit Inspector. No longer updated.
JavaScript
4
star
33

run-this-gist

Chrome extension. Run code from gist.github.com using run-this.appspot.com and ideone.com. It's terribly slow and buggy!
JavaScript
4
star
34

jquery.fn.caret

Cross-browser jQuery plugin (a good one) for caret position handling
JavaScript
3
star
35

tab_character_size

UserScript. 8 spaces for the tab character are too much. I prefer 2.
JavaScript
3
star
36

github-style

UserCSS for github: github-grayrabbit.css. Outdated!
3
star
37

ordered-set

Two Ordered Set implementations: one is backed by a Linked List, another by an Array
JavaScript
3
star
38

nv.github.com

HTML
2
star
39

jsonp.ru

Deprecated, use jsonpwrapper.com
Ruby
2
star
40

n12v.com

Jekyll blog, all posts, and drafts
JavaScript
2
star
41

relative-tabs

Firefox extensions. It does just one thing: open new tab next to active
JavaScript
2
star
42

webkit-inspector-bugs

JavaScript
1
star
43

select-text.js

Element.prototype.select(start, end) and Text.prototype.select(start, end)
JavaScript
1
star
44

markup-quizzes

I post screen shot, you post HTML page.
1
star