| 776 |
lars |
1 |
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
|
|
2 |
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
|
|
3 |
|
|
|
4 |
(function() {
|
|
|
5 |
var mode = CodeMirror.getMode({indentUnit: 2}, "css");
|
|
|
6 |
function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); }
|
|
|
7 |
|
|
|
8 |
// Error, because "foobarhello" is neither a known type or property, but
|
|
|
9 |
// property was expected (after "and"), and it should be in parenthese.
|
|
|
10 |
MT("atMediaUnknownType",
|
|
|
11 |
"[def @media] [attribute screen] [keyword and] [error foobarhello] { }");
|
|
|
12 |
|
|
|
13 |
// Soft error, because "foobarhello" is not a known property or type.
|
|
|
14 |
MT("atMediaUnknownProperty",
|
|
|
15 |
"[def @media] [attribute screen] [keyword and] ([error foobarhello]) { }");
|
|
|
16 |
|
|
|
17 |
// Make sure nesting works with media queries
|
|
|
18 |
MT("atMediaMaxWidthNested",
|
|
|
19 |
"[def @media] [attribute screen] [keyword and] ([property max-width]: [number 25px]) { [tag foo] { } }");
|
|
|
20 |
|
|
|
21 |
MT("atMediaFeatureValueKeyword",
|
|
|
22 |
"[def @media] ([property orientation]: [keyword landscape]) { }");
|
|
|
23 |
|
|
|
24 |
MT("atMediaUnknownFeatureValueKeyword",
|
|
|
25 |
"[def @media] ([property orientation]: [error upsidedown]) { }");
|
|
|
26 |
|
|
|
27 |
MT("tagSelector",
|
|
|
28 |
"[tag foo] { }");
|
|
|
29 |
|
|
|
30 |
MT("classSelector",
|
|
|
31 |
"[qualifier .foo-bar_hello] { }");
|
|
|
32 |
|
|
|
33 |
MT("idSelector",
|
|
|
34 |
"[builtin #foo] { [error #foo] }");
|
|
|
35 |
|
|
|
36 |
MT("tagSelectorUnclosed",
|
|
|
37 |
"[tag foo] { [property margin]: [number 0] } [tag bar] { }");
|
|
|
38 |
|
|
|
39 |
MT("tagStringNoQuotes",
|
|
|
40 |
"[tag foo] { [property font-family]: [variable hello] [variable world]; }");
|
|
|
41 |
|
|
|
42 |
MT("tagStringDouble",
|
|
|
43 |
"[tag foo] { [property font-family]: [string \"hello world\"]; }");
|
|
|
44 |
|
|
|
45 |
MT("tagStringSingle",
|
|
|
46 |
"[tag foo] { [property font-family]: [string 'hello world']; }");
|
|
|
47 |
|
|
|
48 |
MT("tagColorKeyword",
|
|
|
49 |
"[tag foo] {",
|
|
|
50 |
" [property color]: [keyword black];",
|
|
|
51 |
" [property color]: [keyword navy];",
|
|
|
52 |
" [property color]: [keyword yellow];",
|
|
|
53 |
"}");
|
|
|
54 |
|
|
|
55 |
MT("tagColorHex3",
|
|
|
56 |
"[tag foo] { [property background]: [atom #fff]; }");
|
|
|
57 |
|
|
|
58 |
MT("tagColorHex6",
|
|
|
59 |
"[tag foo] { [property background]: [atom #ffffff]; }");
|
|
|
60 |
|
|
|
61 |
MT("tagColorHex4",
|
|
|
62 |
"[tag foo] { [property background]: [atom&error #ffff]; }");
|
|
|
63 |
|
|
|
64 |
MT("tagColorHexInvalid",
|
|
|
65 |
"[tag foo] { [property background]: [atom&error #ffg]; }");
|
|
|
66 |
|
|
|
67 |
MT("tagNegativeNumber",
|
|
|
68 |
"[tag foo] { [property margin]: [number -5px]; }");
|
|
|
69 |
|
|
|
70 |
MT("tagPositiveNumber",
|
|
|
71 |
"[tag foo] { [property padding]: [number 5px]; }");
|
|
|
72 |
|
|
|
73 |
MT("tagVendor",
|
|
|
74 |
"[tag foo] { [meta -foo-][property box-sizing]: [meta -foo-][atom border-box]; }");
|
|
|
75 |
|
|
|
76 |
MT("tagBogusProperty",
|
|
|
77 |
"[tag foo] { [property&error barhelloworld]: [number 0]; }");
|
|
|
78 |
|
|
|
79 |
MT("tagTwoProperties",
|
|
|
80 |
"[tag foo] { [property margin]: [number 0]; [property padding]: [number 0]; }");
|
|
|
81 |
|
|
|
82 |
MT("tagTwoPropertiesURL",
|
|
|
83 |
"[tag foo] { [property background]: [atom url]([string //example.com/foo.png]); [property padding]: [number 0]; }");
|
|
|
84 |
|
|
|
85 |
MT("indent_tagSelector",
|
|
|
86 |
"[tag strong], [tag em] {",
|
|
|
87 |
" [property background]: [atom rgba](",
|
|
|
88 |
" [number 255], [number 255], [number 0], [number .2]",
|
|
|
89 |
" );",
|
|
|
90 |
"}");
|
|
|
91 |
|
|
|
92 |
MT("indent_atMedia",
|
|
|
93 |
"[def @media] {",
|
|
|
94 |
" [tag foo] {",
|
|
|
95 |
" [property color]:",
|
|
|
96 |
" [keyword yellow];",
|
|
|
97 |
" }",
|
|
|
98 |
"}");
|
|
|
99 |
|
|
|
100 |
MT("indent_comma",
|
|
|
101 |
"[tag foo] {",
|
|
|
102 |
" [property font-family]: [variable verdana],",
|
|
|
103 |
" [atom sans-serif];",
|
|
|
104 |
"}");
|
|
|
105 |
|
|
|
106 |
MT("indent_parentheses",
|
|
|
107 |
"[tag foo]:[variable-3 before] {",
|
|
|
108 |
" [property background]: [atom url](",
|
|
|
109 |
"[string blahblah]",
|
|
|
110 |
"[string etc]",
|
|
|
111 |
"[string ]) [keyword !important];",
|
|
|
112 |
"}");
|
|
|
113 |
|
|
|
114 |
MT("font_face",
|
|
|
115 |
"[def @font-face] {",
|
|
|
116 |
" [property font-family]: [string 'myfont'];",
|
|
|
117 |
" [error nonsense]: [string 'abc'];",
|
|
|
118 |
" [property src]: [atom url]([string http://blah]),",
|
|
|
119 |
" [atom url]([string http://foo]);",
|
|
|
120 |
"}");
|
|
|
121 |
|
|
|
122 |
MT("empty_url",
|
|
|
123 |
"[def @import] [tag url]() [tag screen];");
|
|
|
124 |
|
|
|
125 |
MT("parens",
|
|
|
126 |
"[qualifier .foo] {",
|
|
|
127 |
" [property background-image]: [variable fade]([atom #000], [number 20%]);",
|
|
|
128 |
" [property border-image]: [atom linear-gradient](",
|
|
|
129 |
" [atom to] [atom bottom],",
|
|
|
130 |
" [variable fade]([atom #000], [number 20%]) [number 0%],",
|
|
|
131 |
" [variable fade]([atom #000], [number 20%]) [number 100%]",
|
|
|
132 |
" );",
|
|
|
133 |
"}");
|
|
|
134 |
|
|
|
135 |
MT("css_variable",
|
|
|
136 |
":[variable-3 root] {",
|
|
|
137 |
" [variable-2 --main-color]: [atom #06c];",
|
|
|
138 |
"}",
|
|
|
139 |
"[tag h1][builtin #foo] {",
|
|
|
140 |
" [property color]: [atom var]([variable-2 --main-color]);",
|
|
|
141 |
"}");
|
|
|
142 |
|
|
|
143 |
MT("supports",
|
|
|
144 |
"[def @supports] ([keyword not] (([property text-align-last]: [atom justify]) [keyword or] ([meta -moz-][property text-align-last]: [atom justify])) {",
|
|
|
145 |
" [property text-align-last]: [atom justify];",
|
|
|
146 |
"}");
|
|
|
147 |
|
|
|
148 |
MT("document",
|
|
|
149 |
"[def @document] [tag url]([string http://blah]),",
|
|
|
150 |
" [tag url-prefix]([string https://]),",
|
|
|
151 |
" [tag domain]([string blah.com]),",
|
|
|
152 |
" [tag regexp]([string \".*blah.+\"]) {",
|
|
|
153 |
" [builtin #id] {",
|
|
|
154 |
" [property background-color]: [keyword white];",
|
|
|
155 |
" }",
|
|
|
156 |
" [tag foo] {",
|
|
|
157 |
" [property font-family]: [variable Verdana], [atom sans-serif];",
|
|
|
158 |
" }",
|
|
|
159 |
" }");
|
|
|
160 |
|
|
|
161 |
MT("document_url",
|
|
|
162 |
"[def @document] [tag url]([string http://blah]) { [qualifier .class] { } }");
|
|
|
163 |
|
|
|
164 |
MT("document_urlPrefix",
|
|
|
165 |
"[def @document] [tag url-prefix]([string https://]) { [builtin #id] { } }");
|
|
|
166 |
|
|
|
167 |
MT("document_domain",
|
|
|
168 |
"[def @document] [tag domain]([string blah.com]) { [tag foo] { } }");
|
|
|
169 |
|
|
|
170 |
MT("document_regexp",
|
|
|
171 |
"[def @document] [tag regexp]([string \".*blah.+\"]) { [builtin #id] { } }");
|
|
|
172 |
|
|
|
173 |
MT("counter-style",
|
|
|
174 |
"[def @counter-style] [variable binary] {",
|
|
|
175 |
" [property system]: [atom numeric];",
|
|
|
176 |
" [property symbols]: [number 0] [number 1];",
|
|
|
177 |
" [property suffix]: [string \".\"];",
|
|
|
178 |
" [property range]: [atom infinite];",
|
|
|
179 |
" [property speak-as]: [atom numeric];",
|
|
|
180 |
"}");
|
|
|
181 |
|
|
|
182 |
MT("counter-style-additive-symbols",
|
|
|
183 |
"[def @counter-style] [variable simple-roman] {",
|
|
|
184 |
" [property system]: [atom additive];",
|
|
|
185 |
" [property additive-symbols]: [number 10] [variable X], [number 5] [variable V], [number 1] [variable I];",
|
|
|
186 |
" [property range]: [number 1] [number 49];",
|
|
|
187 |
"}");
|
|
|
188 |
|
|
|
189 |
MT("counter-style-use",
|
|
|
190 |
"[tag ol][qualifier .roman] { [property list-style]: [variable simple-roman]; }");
|
|
|
191 |
|
|
|
192 |
MT("counter-style-symbols",
|
|
|
193 |
"[tag ol] { [property list-style]: [atom symbols]([atom cyclic] [string \"*\"] [string \"\\2020\"] [string \"\\2021\"] [string \"\\A7\"]); }");
|
|
|
194 |
})();
|