Skip to content

Commit 9668d31

Browse files
committed
CSSOM philosophy explanation.
1 parent f422281 commit 9668d31

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

README.mdown

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,24 @@ To use it with Node.js or any other CommonJS loader:
3434

3535
➤ npm install cssom
3636

37+
## Don’t use it if...
38+
39+
You parse CSS to mungle, minify or reformat the following code:
40+
41+
```css
42+
div {
43+
background: gray;
44+
background: linear-gradient(to bottom, white 0%, black 100%);
45+
}
46+
```
47+
48+
In CSSOM, `background: gray` [gets overwritten](http://nv.github.io/CSSOM/docs/parse.html#css=div%20%7B%0A%20%20%20%20%20%20background%3A%20gray%3B%0A%20%20%20%20background%3A%20linear-gradient(to%20bottom%2C%20white%200%25%2C%20black%20100%25)%3B%0A%7D). The last same-name property always overwrites all the previous ones.
49+
50+
This pattern is often used to give browsers that don’t understand linear gradients a fallback solution (e.g. gray color in the example). If you do CSS mungling, minification, image inlining, and such, CSSOM.js is not a good solution for you, look for alternatives instead:
51+
52+
* [reworkcss/css](https://github.com/reworkcss/css)
53+
* [csso](https://github.com/css/csso)
54+
3755

3856
## [Specs](http://nv.github.com/CSSOM/spec/)
3957

0 commit comments

Comments
 (0)