Skip to content

Commit 5f54772

Browse files
jsnajdrshellscape
authored andcommitted
fix: double slash comments inside Sass maps (shellscape#60)
* Fix parsing double slash comments inside Sass maps * Upgrade natives module to 1.1.6 to fix Gulp crash on latest Node
1 parent 94de566 commit 5f54772

File tree

3 files changed

+36
-5
lines changed

3 files changed

+36
-5
lines changed

lib/tokenize.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ module.exports = function tokenize (input, options) {
152152

153153
case closeParen:
154154
parentCount--;
155-
isURLArg = !isURLArg && parentCount === 1;
155+
isURLArg = isURLArg && parentCount > 0;
156156
tokens.push([')', ')',
157157
line, pos - offset,
158158
line, next - offset,

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/comment.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,37 @@ describe('Parser → Comment', () => {
107107
{ type: 'paren', value: ')' }
108108
]
109109
},
110+
{
111+
it: 'should parse double slash comments after nested function inside url function',
112+
test: 'url(var()//comment\n)',
113+
loose: true,
114+
expected: [
115+
{ type: 'func', value: 'url' },
116+
{ type: 'paren', value: '(' },
117+
{ type: 'func', value: 'var' },
118+
{ type: 'paren', value: '(' },
119+
{ type: 'paren', value: ')' },
120+
{ type: 'comment', value: 'comment' },
121+
{ type: 'paren', value: ')' }
122+
]
123+
},
124+
{
125+
it: 'should parse double slash comments inside Sass maps',
126+
test: '(a:(b:c)//comment\n)',
127+
loose: true,
128+
expected: [
129+
{ type: 'paren', value: '(' },
130+
{ type: 'word', value: 'a' },
131+
{ type: 'colon', value: ':' },
132+
{ type: 'paren', value: '(' },
133+
{ type: 'word', value: 'b' },
134+
{ type: 'colon', value: ':' },
135+
{ type: 'word', value: 'c' },
136+
{ type: 'paren', value: ')' },
137+
{ type: 'comment', value: 'comment' },
138+
{ type: 'paren', value: ')' }
139+
]
140+
},
110141
{
111142
it: 'should parse only one double slash empty comment',
112143
test: '//\n',

0 commit comments

Comments
 (0)