@acemir/cssom 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.txt +20 -0
- package/README.mdown +64 -0
- package/build/CSSOM.js +2283 -0
- package/lib/CSSConditionRule.js +25 -0
- package/lib/CSSContainerRule.js +50 -0
- package/lib/CSSDocumentRule.js +39 -0
- package/lib/CSSFontFaceRule.js +36 -0
- package/lib/CSSGroupingRule.js +69 -0
- package/lib/CSSHostRule.js +37 -0
- package/lib/CSSImportRule.js +132 -0
- package/lib/CSSKeyframeRule.js +37 -0
- package/lib/CSSKeyframesRule.js +39 -0
- package/lib/CSSLayerBlockRule.js +48 -0
- package/lib/CSSMediaRule.js +53 -0
- package/lib/CSSNestedDeclarations.js +31 -0
- package/lib/CSSOM.js +3 -0
- package/lib/CSSRule.js +42 -0
- package/lib/CSSStartingStyleRule.js +37 -0
- package/lib/CSSStyleDeclaration.js +148 -0
- package/lib/CSSStyleRule.js +200 -0
- package/lib/CSSStyleSheet.js +88 -0
- package/lib/CSSSupportsRule.js +36 -0
- package/lib/CSSValue.js +43 -0
- package/lib/CSSValueExpression.js +344 -0
- package/lib/MatcherList.js +62 -0
- package/lib/MediaList.js +61 -0
- package/lib/StyleSheet.js +17 -0
- package/lib/clone.js +81 -0
- package/lib/index.js +27 -0
- package/lib/parse.js +783 -0
- package/package.json +30 -0
package/LICENSE.txt
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Copyright (c) Nikita Vasilyev
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
4
|
+
a copy of this software and associated documentation files (the
|
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
9
|
+
the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be
|
|
12
|
+
included in all copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.mdown
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# CSSOM
|
|
2
|
+
|
|
3
|
+
CSSOM.js is a CSS parser written in pure JavaScript. It is also a partial implementation of [CSS Object Model](http://dev.w3.org/csswg/cssom/).
|
|
4
|
+
|
|
5
|
+
CSSOM.parse("body {color: black}")
|
|
6
|
+
-> {
|
|
7
|
+
cssRules: [
|
|
8
|
+
{
|
|
9
|
+
selectorText: "body",
|
|
10
|
+
style: {
|
|
11
|
+
0: "color",
|
|
12
|
+
color: "black",
|
|
13
|
+
length: 1
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
]
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
## [Parser demo](https://acemir.github.io/CSSOM/docs/parse.html)
|
|
21
|
+
|
|
22
|
+
Works well in Google Chrome 6+, Safari 5+, Firefox 3.6+, Opera 10.63+.
|
|
23
|
+
Doesn't work in IE < 9 because of unsupported getters/setters.
|
|
24
|
+
|
|
25
|
+
To use CSSOM.js in the browser you might want to build a one-file version that exposes a single `CSSOM` global variable:
|
|
26
|
+
|
|
27
|
+
➤ git clone https://github.com/acemir/CSSOM.git
|
|
28
|
+
➤ cd CSSOM
|
|
29
|
+
➤ node build.js
|
|
30
|
+
build/CSSOM.js is done
|
|
31
|
+
|
|
32
|
+
To use it with Node.js or any other CommonJS loader:
|
|
33
|
+
|
|
34
|
+
➤ npm install @acemir/cssom
|
|
35
|
+
|
|
36
|
+
## Don’t use it if...
|
|
37
|
+
|
|
38
|
+
You parse CSS to mungle, minify or reformat code like this:
|
|
39
|
+
|
|
40
|
+
```css
|
|
41
|
+
div {
|
|
42
|
+
background: gray;
|
|
43
|
+
background: linear-gradient(to bottom, white 0%, black 100%);
|
|
44
|
+
}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
This pattern is often used to give browsers that don’t understand linear gradients a fallback solution (e.g. gray color in the example).
|
|
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).
|
|
49
|
+
It does **NOT** get preserved.
|
|
50
|
+
|
|
51
|
+
If you do CSS mungling, minification, or image inlining, considere using one of the following:
|
|
52
|
+
|
|
53
|
+
* [postcss](https://github.com/postcss/postcss)
|
|
54
|
+
* [reworkcss/css](https://github.com/reworkcss/css)
|
|
55
|
+
* [csso](https://github.com/css/csso)
|
|
56
|
+
* [mensch](https://github.com/brettstimmerman/mensch)
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
## [Tests](https://acemir.github.io/CSSOM/spec/)
|
|
60
|
+
|
|
61
|
+
To run tests locally:
|
|
62
|
+
|
|
63
|
+
➤ git submodule init
|
|
64
|
+
➤ git submodule update
|