Skip to content

Commit ebd3129

Browse files
committed
Fix bug connected with creating new single line comment with quote symbol token.
1 parent 0e1b38a commit ebd3129

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

lib/nodes/inline-comment.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ module.exports = {
99
const first = token;
1010
const bits = [];
1111
let last;
12+
let remainingInput;
1213

1314
while (token) {
1415
if (/\r?\n/.test(token[1])) {
@@ -18,12 +19,8 @@ module.exports = {
1819
bits.push(token[1].substring(0, token[1].indexOf('\n')));
1920

2021
// Get remaining input and retokenize
21-
let remainingInput = token[1].substring(token[1].indexOf('\n'));
22+
remainingInput = token[1].substring(token[1].indexOf('\n'));
2223
remainingInput += this.input.css.valueOf().substring(this.tokenizer.position());
23-
24-
// Replace tokenizer to retokenize the rest of the string
25-
this.input = new Input(remainingInput);
26-
this.tokenizer = tokenizer(this.input);
2724
} else {
2825
// If the tokenizer went to the next line go back
2926
this.tokenizer.back(token);
@@ -37,8 +34,15 @@ module.exports = {
3734
}
3835

3936
const newToken = ['comment', bits.join(''), first[2], first[3], last[2], last[3]];
40-
4137
this.inlineComment(newToken);
38+
39+
// Replace tokenizer to retokenize the rest of the string
40+
// we need replace it after we added new token with inline comment because token position is calculated for old input (#145)
41+
if (remainingInput) {
42+
this.input = new Input(remainingInput);
43+
this.tokenizer = tokenizer(this.input);
44+
}
45+
4246
return true;
4347
} else if (token[1] === '/') {
4448
// issue #135

0 commit comments

Comments
 (0)