stylus-source 0.15.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (113) hide show
  1. data/.DS_Store +0 -0
  2. data/README.md +3 -0
  3. data/lib/.DS_Store +0 -0
  4. data/lib/node_modules/cssom/.idea/CSSOM.iml +9 -0
  5. data/lib/node_modules/cssom/.idea/dictionaries/nv.xml +3 -0
  6. data/lib/node_modules/cssom/.idea/encodings.xml +5 -0
  7. data/lib/node_modules/cssom/.idea/misc.xml +17 -0
  8. data/lib/node_modules/cssom/.idea/modules.xml +9 -0
  9. data/lib/node_modules/cssom/.idea/projectCodeStyle.xml +82 -0
  10. data/lib/node_modules/cssom/.idea/vcs.xml +8 -0
  11. data/lib/node_modules/cssom/.idea/workspace.xml +467 -0
  12. data/lib/node_modules/cssom/.livereload +19 -0
  13. data/lib/node_modules/cssom/Jakefile +37 -0
  14. data/lib/node_modules/cssom/README.mdown +33 -0
  15. data/lib/node_modules/cssom/Rakefile +23 -0
  16. data/lib/node_modules/cssom/docs/.livereload +19 -0
  17. data/lib/node_modules/cssom/docs/bar.css +3 -0
  18. data/lib/node_modules/cssom/docs/demo.css +0 -0
  19. data/lib/node_modules/cssom/docs/foo.css +4 -0
  20. data/lib/node_modules/cssom/docs/parse.html +170 -0
  21. data/lib/node_modules/cssom/docs/parse2.html +431 -0
  22. data/lib/node_modules/cssom/index.html +100 -0
  23. data/lib/node_modules/cssom/lib/CSSImportRule.js +34 -0
  24. data/lib/node_modules/cssom/lib/CSSMediaRule.js +38 -0
  25. data/lib/node_modules/cssom/lib/CSSOM.js +3 -0
  26. data/lib/node_modules/cssom/lib/CSSRule.js +38 -0
  27. data/lib/node_modules/cssom/lib/CSSStyleDeclaration.js +130 -0
  28. data/lib/node_modules/cssom/lib/CSSStyleRule.js +187 -0
  29. data/lib/node_modules/cssom/lib/CSSStyleSheet.js +85 -0
  30. data/lib/node_modules/cssom/lib/MediaList.js +61 -0
  31. data/lib/node_modules/cssom/lib/StyleSheet.js +15 -0
  32. data/lib/node_modules/cssom/lib/clone.js +69 -0
  33. data/lib/node_modules/cssom/lib/index.js +10 -0
  34. data/lib/node_modules/cssom/lib/parse.js +195 -0
  35. data/lib/node_modules/cssom/media.html +17 -0
  36. data/lib/node_modules/cssom/package.json +30 -0
  37. data/lib/node_modules/cssom/plugins/toHTML.js +32 -0
  38. data/lib/node_modules/cssom/server/index.html +22 -0
  39. data/lib/node_modules/cssom/server/index.js +21 -0
  40. data/lib/node_modules/cssom/shorthands.html +21 -0
  41. data/lib/node_modules/cssom/test/CSSStyleDeclaration.test.js +35 -0
  42. data/lib/node_modules/cssom/test/CSSStyleRule.test.js +12 -0
  43. data/lib/node_modules/cssom/test/CSSStyleSheet.test.js +16 -0
  44. data/lib/node_modules/cssom/test/MediaList.test.js +21 -0
  45. data/lib/node_modules/cssom/test/clone.test.js +38 -0
  46. data/lib/node_modules/cssom/test/fixtures/dummy.css +3 -0
  47. data/lib/node_modules/cssom/test/helper.js +97 -0
  48. data/lib/node_modules/cssom/test/index.html +42 -0
  49. data/lib/node_modules/cssom/test/parse.test.js +346 -0
  50. data/lib/node_modules/cssom/test/vendor/qunit.css +189 -0
  51. data/lib/node_modules/cssom/test/vendor/qunit.js +1341 -0
  52. data/lib/node_modules/growl/History.md +16 -0
  53. data/lib/node_modules/growl/Readme.md +74 -0
  54. data/lib/node_modules/growl/lib/growl.js +82 -0
  55. data/lib/node_modules/growl/package.json +6 -0
  56. data/lib/node_modules/growl/test.js +17 -0
  57. data/lib/stylus/colors.js +156 -0
  58. data/lib/stylus/convert/css.js +130 -0
  59. data/lib/stylus/errors.js +58 -0
  60. data/lib/stylus/functions/image.js +120 -0
  61. data/lib/stylus/functions/index.js +722 -0
  62. data/lib/stylus/functions/index.styl +123 -0
  63. data/lib/stylus/functions/url.js +98 -0
  64. data/lib/stylus/lexer.js +728 -0
  65. data/lib/stylus/middleware.js +223 -0
  66. data/lib/stylus/nodes/arguments.js +65 -0
  67. data/lib/stylus/nodes/binop.js +54 -0
  68. data/lib/stylus/nodes/block.js +99 -0
  69. data/lib/stylus/nodes/boolean.js +103 -0
  70. data/lib/stylus/nodes/call.js +57 -0
  71. data/lib/stylus/nodes/charset.js +42 -0
  72. data/lib/stylus/nodes/comment.js +32 -0
  73. data/lib/stylus/nodes/each.js +56 -0
  74. data/lib/stylus/nodes/expression.js +168 -0
  75. data/lib/stylus/nodes/fontface.js +55 -0
  76. data/lib/stylus/nodes/function.js +104 -0
  77. data/lib/stylus/nodes/group.js +79 -0
  78. data/lib/stylus/nodes/hsla.js +256 -0
  79. data/lib/stylus/nodes/ident.js +127 -0
  80. data/lib/stylus/nodes/if.js +55 -0
  81. data/lib/stylus/nodes/import.js +30 -0
  82. data/lib/stylus/nodes/index.js +52 -0
  83. data/lib/stylus/nodes/jsliteral.js +32 -0
  84. data/lib/stylus/nodes/keyframes.js +78 -0
  85. data/lib/stylus/nodes/literal.js +92 -0
  86. data/lib/stylus/nodes/media.js +42 -0
  87. data/lib/stylus/nodes/node.js +209 -0
  88. data/lib/stylus/nodes/null.js +72 -0
  89. data/lib/stylus/nodes/page.js +43 -0
  90. data/lib/stylus/nodes/params.js +72 -0
  91. data/lib/stylus/nodes/property.js +72 -0
  92. data/lib/stylus/nodes/return.js +44 -0
  93. data/lib/stylus/nodes/rgba.js +335 -0
  94. data/lib/stylus/nodes/root.js +50 -0
  95. data/lib/stylus/nodes/selector.js +57 -0
  96. data/lib/stylus/nodes/string.js +120 -0
  97. data/lib/stylus/nodes/ternary.js +51 -0
  98. data/lib/stylus/nodes/unaryop.js +46 -0
  99. data/lib/stylus/nodes/unit.js +207 -0
  100. data/lib/stylus/parser.js +1514 -0
  101. data/lib/stylus/renderer.js +157 -0
  102. data/lib/stylus/source.rb +7 -0
  103. data/lib/stylus/stack/frame.js +66 -0
  104. data/lib/stylus/stack/index.js +146 -0
  105. data/lib/stylus/stack/scope.js +53 -0
  106. data/lib/stylus/stylus.js +102 -0
  107. data/lib/stylus/token.js +53 -0
  108. data/lib/stylus/utils.js +237 -0
  109. data/lib/stylus/visitor/compiler.js +472 -0
  110. data/lib/stylus/visitor/evaluator.js +1070 -0
  111. data/lib/stylus/visitor/index.js +31 -0
  112. data/stylus-source.gemspec +15 -0
  113. metadata +158 -0
@@ -0,0 +1,30 @@
1
+ {
2
+ "name": "cssom",
3
+ "description": "CSS Object Model implementation and CSS parser",
4
+ "keywords": ["CSS", "CSSOM", "parser", "styleSheet"],
5
+ "version": "0.2.0",
6
+ "homepage": "https://github.com/NV/CSSOM",
7
+ "author": "Nikita Vasilyev <me@elv1s.ru>",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git://github.com/NV/CSSOM.git"
11
+ },
12
+ "bugs": {
13
+ "web": "https://github.com/NV/CSSOM/issues"
14
+ },
15
+ "directories": {
16
+ "doc": "./doc",
17
+ "lib": "./lib",
18
+ "test": "./test"
19
+ },
20
+ "main": "./lib/index.js",
21
+ "engines": {
22
+ "node": ">=0.2.0"
23
+ },
24
+ "licenses": [
25
+ {
26
+ "type": "MIT",
27
+ "url": "http://creativecommons.org/licenses/MIT/"
28
+ }
29
+ ]
30
+ }
@@ -0,0 +1,32 @@
1
+ /**
2
+ * return {string}
3
+ */
4
+ function toHTML(){
5
+ var result = "";
6
+ var rules = this.cssRules;
7
+ var length = rules.length;
8
+ for (var i = 0; i < length; i++) {
9
+ var rule = rules[i];
10
+ if (rule) {
11
+ result += "<span class='rule'><b class='selector'>" + rule.selectorText + "</b> <span class='brace-open'>{</span>";
12
+ var style = rule.style;
13
+ if (!style) continue;
14
+ var jj = style.length;
15
+ if (jj) {
16
+ for (var j = 0; j < jj; j++) {
17
+ var name = style[j];
18
+ result += "\n<span class='name'> " + name + "</span><span class='colon'>: </span><span class='value'>"
19
+ + style[name] + "</span><span class='semicolon'>;</span>";
20
+ }
21
+ }
22
+ result += "<span class='brace-close'>\n}\n</span></span>";
23
+ }
24
+ }
25
+ return result;
26
+ }
27
+
28
+
29
+
30
+ if (typeof exports != "undefined") {
31
+ exports.toHTML = toHTML;
32
+ }
@@ -0,0 +1,22 @@
1
+ <!DOCTYPE HTML>
2
+ <html>
3
+ <head>
4
+ <title></title>
5
+ <script>
6
+ var xhr = new XMLHttpRequest();
7
+ xhr.open("POST", "http://localhost:8124/css_save", true);
8
+ xhr.setRequestHeader("x-path", "/tmp/test.txt");
9
+ xhr.onreadystatechange = function (aEvt) {
10
+ console.log(aEvt)
11
+ };
12
+ xhr.send("asdfsdf sdfkjs dkf");
13
+ </script>
14
+ </head>
15
+ <body>
16
+ <form action="http://localhost:8124/css_save" method="POST">
17
+ <input name="path" value="file:///Users/nv/Code/CSSOM/server/index.html">
18
+ <textarea name="content">Fuu</textarea>
19
+ <button>Submit</button>
20
+ </form>
21
+ </body>
22
+ </html>
@@ -0,0 +1,21 @@
1
+ var http = require('http');
2
+ var fs = require('fs');
3
+
4
+ http.createServer(function(request, response) {
5
+ // console.dir(request);
6
+ // request.setEncoding("utf8");
7
+
8
+ // console.dir(request.headers);
9
+ var start = Date.now();
10
+ var path = request.headers["x-path"];
11
+
12
+
13
+ request.on("data", function(data){
14
+ console.log(fs.writeFileSync(path, data));
15
+ response.writeHead(200, {'Content-Type': 'text/plain'});
16
+ response.end(path + ' saved!\n');
17
+ var end = Date.now();
18
+ console.log(end - start + "ms");
19
+ });
20
+
21
+ }).listen(8124);
@@ -0,0 +1,21 @@
1
+ <!DOCTYPE HTML>
2
+ <html>
3
+ <head>
4
+ <title></title>
5
+ <style type="text/css">
6
+ body {
7
+ font: 14px sans-serif;
8
+ border: none;
9
+ background-repeat: no-repeat;
10
+ }
11
+ </style>
12
+ </head>
13
+ <body>
14
+ fuuu
15
+ <script type="text/javascript">
16
+ onload = function(){
17
+ console.dir(document.styleSheets[0].cssRules[0].style)
18
+ }
19
+ </script>
20
+ </body>
21
+ </html>
@@ -0,0 +1,35 @@
1
+ test("CSSStyleDeclaration", function(){
2
+ var d = new CSSOM.CSSStyleDeclaration;
3
+
4
+ d.setProperty("color", "purple");
5
+ equalOwnProperties(d, {
6
+ 0: "color",
7
+ length: 1,
8
+ color: "purple"
9
+ });
10
+
11
+ d.setProperty("width", "128px", "important");
12
+ equalOwnProperties(d, {
13
+ 0: "color",
14
+ 1: "width",
15
+ length: 2,
16
+ color: "purple",
17
+ width: "128px"
18
+ });
19
+
20
+ equal(d.cssText, "color: purple; width: 128px !important;");
21
+
22
+ equal(d.getPropertyValue("color"), "purple");
23
+ equal(d.getPropertyValue("width"), "128px");
24
+ equal(d.getPropertyValue("position"), "");
25
+
26
+ strictEqual(d.getPropertyPriority("color"), "");
27
+ strictEqual(d.getPropertyPriority("width"), "important");
28
+ strictEqual(d.getPropertyPriority("position"), "");
29
+
30
+ d.setProperty("color", "green");
31
+ d.removeProperty("width");
32
+
33
+ equal(d.cssText, "color: green;");
34
+
35
+ });
@@ -0,0 +1,12 @@
1
+ test("CSSStyleRule", function(){
2
+ var r = new CSSOM.CSSStyleRule;
3
+ r.cssText = "h1:first-of-type {\n\tfont-size: 3em\n}";
4
+
5
+ equal(r.cssText, "h1:first-of-type {font-size: 3em;}");
6
+ equal(r.selectorText, "h1:first-of-type");
7
+
8
+ r.selectorText = "h1.title";
9
+ equal(r.selectorText, "h1.title");
10
+ equal(r.cssText, "h1.title {font-size: 3em;}");
11
+
12
+ });
@@ -0,0 +1,16 @@
1
+ test("CSSStyleSheet", function(){
2
+ var s = new CSSOM.CSSStyleSheet;
3
+ deepEqual(s.cssRules, []);
4
+
5
+ s.insertRule("a {color: blue}", 0);
6
+ equal(s.cssRules.length, 1);
7
+
8
+ s.insertRule("a *:first-child, a img {border: none}", 1);
9
+ equal(s.cssRules.length, 2);
10
+
11
+ s.deleteRule(1);
12
+ equal(s.cssRules.length, 1);
13
+
14
+ s.deleteRule(0);
15
+ deepEqual(s.cssRules, []);
16
+ });
@@ -0,0 +1,21 @@
1
+ test("MediaList", function(){
2
+ var m = new CSSOM.MediaList;
3
+ strictEqual(m.length, 0);
4
+
5
+ m.appendMedium("handheld");
6
+ m.appendMedium("screen");
7
+ m.appendMedium("only screen and (max-device-width: 480px)");
8
+
9
+ m.deleteMedium("screen");
10
+
11
+ strictEqual(m[2], undefined);
12
+
13
+ var expected = {
14
+ 0: "handheld",
15
+ 1: "only screen and (max-device-width: 480px)",
16
+ length: 2
17
+ };
18
+
19
+ equalOwnProperties(m, expected);
20
+ equal(m.mediaText, [].join.call(expected, ", "));
21
+ });
@@ -0,0 +1,38 @@
1
+ test("clone", function(){
2
+ var css = {
3
+ cssRules: {
4
+ 0: {
5
+ cssText: "* {background: #fff !important; color: #000 !important}",
6
+ parentRule: null,
7
+ selectorText: "body",
8
+ type: 1,
9
+ style: {
10
+ 0: "background",
11
+ 1: "color",
12
+ background: "#fff",
13
+ color: "#000",
14
+ cssText: "background: #fff !important; color: #000 !important",
15
+ length: 2,
16
+ getPropertyPriority: function(){
17
+ return "important";
18
+ }
19
+ }
20
+ },
21
+ length: 1
22
+ },
23
+ disabled: false,
24
+ href: "http://usercss.ru/black-on-white.css",
25
+ media: {
26
+ length: 0,
27
+ mediaText: ""
28
+ },
29
+ ownerRule: null,
30
+ parentStyleSheet: null,
31
+ title: null,
32
+ type: "text/css"
33
+ };
34
+ css.rule = css.cssRules;
35
+ css.cssRules[0].parentStyleSheet = css;
36
+ css.cssRules[0].style.parentRule = css.cssRules[0];
37
+ hasOwnProperties(css, CSSOM.clone(css), "Should be at least a subset of original object");
38
+ });
@@ -0,0 +1,3 @@
1
+ body {
2
+ font-size: 12px;
3
+ }
@@ -0,0 +1,97 @@
1
+ /**
2
+ * @param {string} actual
3
+ * @param {string} expected
4
+ * @param {string} [message]
5
+ * TODO: http://github.com/jquery/qunit/issues#issue/39
6
+ */
7
+ function equalOwnProperties(actual, expected, message) {
8
+ var actualDummy = cloneOwnProperties(actual);
9
+ var expectedDummy = cloneOwnProperties(expected);
10
+ deepEqual(actualDummy, expectedDummy, message);
11
+ }
12
+
13
+
14
+ /**
15
+ * Make a deep copy of an object
16
+ * @param {Object|Array} object
17
+ * @return {Object|Array}
18
+ */
19
+ function cloneOwnProperties(object) {
20
+ var result = {};
21
+ for (var key in object) {
22
+ if (key.charAt(0) == "_" || !object.hasOwnProperty(key)) {
23
+ continue;
24
+ }
25
+ if (typeof object[key] == "object") {
26
+ result[key] = cloneOwnProperties(object[key]);
27
+ } else {
28
+ result[key] = object[key];
29
+ }
30
+ }
31
+ return result;
32
+ }
33
+
34
+
35
+ /**
36
+ * @param {Object|Array} actual
37
+ * @param {Object|Array} expected
38
+ * @param {string} message
39
+ */
40
+ function hasOwnProperties(actual, expected, message){
41
+ var diff = subsetOfOwnProperties(actual, expected);
42
+ if (diff) {
43
+ QUnit.push(false, diff, {}, message);
44
+ } else {
45
+ // QUnit.jsDump is so dumb. It can't even parse circular references.
46
+ QUnit.push(true, "okay", "okay", message);
47
+ }
48
+ }
49
+
50
+
51
+ function subsetOfOwnProperties(base, another) {
52
+ if (base === another) {
53
+ return false;
54
+ }
55
+
56
+ if (typeof base != "object" || typeof another != "object") {
57
+ return another;
58
+ }
59
+
60
+ var diff = {};
61
+ var isDiff = false;
62
+ for (var key in another) {
63
+ if (key.charAt(0) == "_" || !another.hasOwnProperty(key)) {
64
+ continue;
65
+ }
66
+ if (key in base) {
67
+ if (base[key] === another[key]) {
68
+ // skip equal pairs
69
+ } else {
70
+ var sub = subsetOfOwnProperties(base[key], another[key]);
71
+ if (sub) {
72
+ isDiff = true;
73
+ diff[key] = sub;
74
+ }
75
+ }
76
+ } else {
77
+ isDiff = true;
78
+ diff[key] = another[key];
79
+ }
80
+ }
81
+
82
+ return isDiff ? diff : false;
83
+ }
84
+
85
+
86
+ /**
87
+ * Compare two stylesheets
88
+ * @param {string} css
89
+ * @param {Object} expected
90
+ * @param {string} [message]
91
+ */
92
+ function compare(css, expected, message) {
93
+ var actual = CSSOM.parse(css);
94
+ test(css, function(){
95
+ equalOwnProperties(actual, expected, message || "");
96
+ });
97
+ }
@@ -0,0 +1,42 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>CSSOM tests</title>
5
+ <link rel="stylesheet" href="vendor/qunit.css" type="text/css">
6
+ <script src="vendor/qunit.js"></script>
7
+ <script>
8
+ var exports = {};
9
+ function require(){
10
+ return exports;
11
+ }
12
+ </script>
13
+ <script src="../lib/CSSStyleDeclaration.js"></script>
14
+ <script src="../lib/CSSRule.js"></script>
15
+ <script src="../lib/CSSStyleRule.js"></script>
16
+ <script src="../lib/CSSImportRule.js"></script>
17
+ <script src="../lib/MediaList.js"></script>
18
+ <script src="../lib/CSSMediaRule.js"></script>
19
+ <script src="../lib/StyleSheet.js"></script>
20
+ <script src="../lib/CSSStyleSheet.js"></script>
21
+ <script src="../lib/parse.js"></script>
22
+ <script src="../lib/clone.js"></script>
23
+ <script>
24
+ window.CSSOM = exports;
25
+ </script>
26
+ <script src="helper.js"></script>
27
+ <script src="CSSStyleSheet.test.js"></script>
28
+ <script src="CSSStyleDeclaration.test.js"></script>
29
+ <script src="CSSStyleRule.test.js"></script>
30
+ <script src="MediaList.test.js"></script>
31
+ <script src="parse.test.js"></script>
32
+ <script src="clone.test.js"></script>
33
+ </head>
34
+ <body id="qunit-wrapper">
35
+ <h1 id="qunit-header">CSSOM tests</h1>
36
+ <h2 id="qunit-banner"></h2>
37
+ <div id="qunit-testrunner-toolbar"></div>
38
+ <ol id="qunit-tests"></ol>
39
+ <h2 id="qunit-userAgent"></h2>
40
+ <div id="qunit-fixture">test markup</div>
41
+ </body>
42
+ </html>
@@ -0,0 +1,346 @@
1
+ var TESTS = [
2
+ {
3
+ input: "/* fuuuu */",
4
+ result: {
5
+ cssRules: []
6
+ }
7
+ },
8
+ {
9
+ input: "/**/",
10
+ result: {
11
+ cssRules: []
12
+ }
13
+ },
14
+ {
15
+ input: "/*a {content: '* {color:#000}'}*/",
16
+ result: {
17
+ cssRules: []
18
+ }
19
+ },
20
+ {
21
+ input: "a {color: red}",
22
+ result: {
23
+ cssRules: [
24
+ {
25
+ selectorText: "a",
26
+ style: {
27
+ 0: "color",
28
+ color: "red",
29
+ length: 1
30
+ }
31
+ }
32
+ ]
33
+ }
34
+ },
35
+ {
36
+ input: ".left {float: left;}",
37
+ result: {
38
+ cssRules: [
39
+ {
40
+ selectorText: ".left",
41
+ style: {
42
+ 0: "float",
43
+ float: "left",
44
+ length: 1
45
+ }
46
+ }
47
+ ]
48
+ }
49
+ },
50
+ {
51
+ input: "h1 {font-family: 'Times New Roman', Helvetica Neue, sans-serif }",
52
+ result: {
53
+ cssRules: [
54
+ {
55
+ selectorText: "h1",
56
+ style: {
57
+ 0: "font-family",
58
+ "font-family": "'Times New Roman', Helvetica Neue, sans-serif",
59
+ length: 1
60
+ }
61
+ }
62
+ ]
63
+ }
64
+ },
65
+ {
66
+ input: "h2 {font: normal\n1.6em\r\nTimes New Roman,\tserif ;}",
67
+ result: {
68
+ cssRules: [
69
+ {
70
+ selectorText: "h2",
71
+ style: {
72
+ 0: "font",
73
+ font: "normal 1.6em Times New Roman, serif",
74
+ length: 1
75
+ }
76
+ }
77
+ ]
78
+ }
79
+ },
80
+ {
81
+ input: ".icon>*{background-image: url(../images/ramona_strong.gif);}",
82
+ result: {
83
+ cssRules: [
84
+ {
85
+ selectorText: ".icon>*",
86
+ style: {
87
+ 0: "background-image",
88
+ "background-image": "url(../images/ramona_strong.gif)",
89
+ length: 1
90
+ }
91
+ }
92
+ ]
93
+ }
94
+ },
95
+ {
96
+ input: "*/**/{}",
97
+ result: {
98
+ cssRules: [
99
+ {
100
+ selectorText: "*",
101
+ style: {
102
+ length: 0
103
+ }
104
+ }
105
+ ]
106
+ }
107
+ },
108
+ {
109
+ input: "/**/*{}",
110
+ result: {
111
+ cssRules: [
112
+ {
113
+ selectorText: "*",
114
+ style: {
115
+ length: 0
116
+ }
117
+ }
118
+ ]
119
+ }
120
+ },
121
+ {
122
+ input: "* /**/*{}",
123
+ result: {
124
+ cssRules: [
125
+ {
126
+ selectorText: "* *",
127
+ style: {
128
+ length: 0
129
+ }
130
+ }
131
+ ]
132
+ }
133
+ },
134
+ {
135
+ input: "*/*/*/ *{}",
136
+ result: {
137
+ cssRules: [
138
+ {
139
+ selectorText: "* *",
140
+ style: {
141
+ length: 0
142
+ }
143
+ }
144
+ ]
145
+ }
146
+ },
147
+ {
148
+ input: "#a {b:c;}\n#d {e:f}",
149
+ result: {
150
+ cssRules: [
151
+ {
152
+ selectorText: "#a",
153
+ style: {
154
+ 0: "b",
155
+ b: "c",
156
+ length: 1
157
+ }
158
+ }, {
159
+ selectorText: "#d",
160
+ style: {
161
+ 0: "e",
162
+ e: "f",
163
+ length: 1
164
+ }
165
+ }
166
+ ]
167
+ }
168
+ },
169
+ {
170
+ input: "* { border: none } \n#foo {font-size: 12px; background:#fff;}",
171
+ result: {
172
+ cssRules: [
173
+ {
174
+ selectorText: "*",
175
+ style: {
176
+ 0: "border",
177
+ border: "none",
178
+ length: 1
179
+ }
180
+ },
181
+ {
182
+ selectorText: "#foo",
183
+ style: {
184
+ 0: "font-size",
185
+ "font-size": "12px",
186
+ 1: "background",
187
+ background: "#fff",
188
+ length: 2
189
+ }
190
+ }
191
+ ]
192
+ }
193
+ },
194
+ {
195
+ input: "span {display: inline-block !important; vertical-align: middle !important} .error{color:red!important;}",
196
+ result: {
197
+ cssRules: [
198
+ {
199
+ selectorText: "span",
200
+ style: {
201
+ 0: "display",
202
+ 1: "vertical-align",
203
+ display: "inline-block",
204
+ "vertical-align": "middle",
205
+ length: 2
206
+ }
207
+ },
208
+ {
209
+ selectorText: ".error",
210
+ style: {
211
+ 0: "color",
212
+ color: "red",
213
+ length: 1
214
+ }
215
+ }
216
+ ]
217
+ }
218
+ },
219
+ {
220
+ input: "@media handheld, only screen and (max-device-width: 480px) {body{max-width:480px}}",
221
+ result: {
222
+ cssRules: [
223
+ {
224
+ media: {
225
+ 0: "handheld",
226
+ 1: "only screen and (max-device-width: 480px)",
227
+ length: 2
228
+ },
229
+ cssRules: [
230
+ {
231
+ selectorText: "body",
232
+ style: {
233
+ 0: "max-width",
234
+ "max-width": "480px",
235
+ length: 1
236
+ }
237
+ }
238
+ ]
239
+ }
240
+ ]
241
+ }
242
+ },
243
+ {
244
+ input: "@media screen, screen, screen {/* Match Firefox and Opera behavior here rather than WebKit. \nSane person shouldn't write like this anyway. */}",
245
+ result: {
246
+ cssRules: [
247
+ {
248
+ media: {
249
+ 0: "screen",
250
+ 1: "screen",
251
+ 2: "screen",
252
+ length: 3
253
+ },
254
+ cssRules: []
255
+ }
256
+ ]
257
+ }
258
+ },
259
+ {
260
+ input: "@media/**/print {*{background:#fff}}",
261
+ result: {
262
+ cssRules: [
263
+ {
264
+ media: {
265
+ 0: "print",
266
+ length: 1
267
+ },
268
+ cssRules: [
269
+ {
270
+ selectorText: "*",
271
+ style: {
272
+ 0: "background",
273
+ background: "#fff",
274
+ length: 1
275
+ }
276
+ }
277
+ ]
278
+ }
279
+ ]
280
+ }
281
+ },
282
+ {
283
+ input: "a{}@media all{b{color:#000}}",
284
+ result: {
285
+ cssRules: [
286
+ {
287
+ selectorText: "a",
288
+ style: {
289
+ length: 0
290
+ }
291
+ },
292
+ {
293
+ media: {
294
+ 0: "all",
295
+ length: 1
296
+ },
297
+ cssRules: [
298
+ {
299
+ selectorText: "b",
300
+ style: {
301
+ 0: "color",
302
+ color: "#000",
303
+ length: 1
304
+ }
305
+ }
306
+ ]
307
+ }
308
+ ]
309
+ }
310
+ },
311
+ {
312
+ input: "@mediaall {}",
313
+ result: {
314
+ cssRules: []
315
+ }
316
+ },
317
+ {
318
+ input: "some invalid junk @media projection {body{background:black}}",
319
+ result: {
320
+ cssRules: [
321
+ {
322
+ media: {
323
+ 0: "projection",
324
+ length: 1
325
+ },
326
+ cssRules: [
327
+ {
328
+ selectorText: "body",
329
+ style: {
330
+ 0: "background",
331
+ background: "black",
332
+ length: 1
333
+ }
334
+ }
335
+ ]
336
+ }
337
+ ]
338
+ }
339
+ }
340
+ ];
341
+
342
+
343
+ // Run tests.
344
+ for (var i=0; i<TESTS.length; i++) {
345
+ compare(TESTS[i].input, TESTS[i].result, TESTS[i].name);
346
+ }