Skip to content

Commit ce56f46

Browse files
fedykjonathanong
authored andcommitted
Add case in test, when the comment is between selector. Add Simple solution this problem (remove all comments).
1 parent 212d7d4 commit ce56f46

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

index.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
module.exports = function(css, options){
32
options = options || {};
43

@@ -170,7 +169,9 @@ module.exports = function(css, options){
170169
function selector() {
171170
var m = match(/^([^{]+)/);
172171
if (!m) return;
173-
return trim(m[0]).split(/\s*,\s*/);
172+
/* @fix Remove all comments from selectors
173+
* http://ostermiller.org/findcomment.html */
174+
return trim(m[0]).replace(/\/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*\/+/g, '').split(/\s*,\s*/);
174175
}
175176

176177
/**

test/cases/comment.css

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* 1 */
22

3-
body { /* 2 */
3+
head, /* footer, */body/*, nav */ { /* 2 */
44
/* 3 */
55
/**/foo: 'bar';
66
/* 4 */

test/cases/comment.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
{
2121
"type": "rule",
2222
"selectors": [
23+
"head",
2324
"body"
2425
],
2526
"declarations": [
@@ -29,11 +30,11 @@
2930
"position": {
3031
"start": {
3132
"line": 3,
32-
"column": 8
33+
"column": 37
3334
},
3435
"end": {
3536
"line": 3,
36-
"column": 15
37+
"column": 44
3738
},
3839
"source": "comment.css"
3940
}

0 commit comments

Comments
 (0)