Skip to content

Commit 27e8f61

Browse files
committed
fix comments within rulesets. Closes #30
1 parent b35702a commit 27e8f61

File tree

4 files changed

+51
-27
lines changed

4 files changed

+51
-27
lines changed

index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,13 +143,13 @@ module.exports = function(css){
143143
var decls = [];
144144

145145
if (!open()) return;
146-
comments();
146+
comments(decls);
147147

148148
// declarations
149149
var decl;
150150
while (decl = declaration()) {
151151
decls.push(decl);
152-
comments();
152+
comments(decls);
153153
}
154154

155155
if (!close()) return;

test/cases/comment.css

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
1-
/* foo */
2-
/* bar */
3-
/* baz
1+
/* 1 */
42

5-
asdfasdfasdf
6-
asdfasdfasdf
7-
asdfasdfasdf
8-
asdfasdfasdf
3+
body { /* 2 */
4+
/* 3 */
5+
/**/foo: 'bar';
6+
/* 4 */
7+
} /* 5 */
98

10-
*/
9+
/* 6 */
1110

12-
foo { /* hey */
13-
/**/ bar: baz; /* hey */ /* hey */
14-
}

test/cases/comment.json

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,45 @@
44
"rules": [
55
{
66
"type": "comment",
7-
"comment": " foo "
8-
},
9-
{
10-
"type": "comment",
11-
"comment": " bar "
12-
},
13-
{
14-
"type": "comment",
15-
"comment": " baz\n\nasdfasdfasdf\nasdfasdfasdf\nasdfasdfasdf\nasdfasdfasdf\n\n"
7+
"comment": " 1 "
168
},
179
{
1810
"type": "rule",
1911
"selectors": [
20-
"foo"
12+
"body"
2113
],
2214
"declarations": [
15+
{
16+
"type": "comment",
17+
"comment": " 2 "
18+
},
19+
{
20+
"type": "comment",
21+
"comment": " 3 "
22+
},
23+
{
24+
"type": "comment",
25+
"comment": ""
26+
},
2327
{
2428
"type": "declaration",
25-
"property": "bar",
26-
"value": "baz"
29+
"property": "foo",
30+
"value": "'bar'"
31+
},
32+
{
33+
"type": "comment",
34+
"comment": " 4 "
2735
}
2836
]
37+
},
38+
{
39+
"type": "comment",
40+
"comment": " 5 "
41+
},
42+
{
43+
"type": "comment",
44+
"comment": " 6 "
2945
}
3046
]
3147
}
32-
}
48+
}

test/cases/comment.url.json

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,25 @@
1616
"foo"
1717
],
1818
"declarations": [
19+
{
20+
"type": "comment",
21+
"comment": "/"
22+
},
23+
{
24+
"type": "comment",
25+
"comment": " something "
26+
},
1927
{
2028
"type": "declaration",
2129
"property": "bar",
2230
"value": "baz"
31+
},
32+
{
33+
"type": "comment",
34+
"comment": " http://foo.com/bar/baz.html "
2335
}
2436
]
2537
}
2638
]
2739
}
28-
}
40+
}

0 commit comments

Comments
 (0)