Skip to content

Commit 4419f97

Browse files
committed
fix(parser): reset node after comment close #7
1 parent 2e2084f commit 4419f97

File tree

3 files changed

+26
-2
lines changed

3 files changed

+26
-2
lines changed

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,7 @@
9292
},
9393
"lint-staged": {
9494
"*.{js,jsx,ts,tsx,json,css,less,scss,md}": [
95-
"prettier --write",
96-
"git add"
95+
"prettier --write"
9796
]
9897
},
9998
"prettier": {

src/parse.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ function parseOpenTag() {
185185
while (++index < count) {
186186
token = tokens[index];
187187
if (token.type === TokenKind.OpenTagEnd) {
188+
node = void 0;
188189
break;
189190
}
190191
appendLiteral();

src/test/issue_7.spec.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
* @since 2020-09-09 22:43:03
3+
* @author acrazing <[email protected]>
4+
*/
5+
6+
import { parse } from '../parse';
7+
import { tag, text } from '../parse.spec';
8+
9+
describe('issue #7', () => {
10+
it('should parse comment as expected', () => {
11+
expect(parse('<!-- it is comment -->\n-\n')).toEqual([
12+
tag(
13+
'<!-- it is comment -->',
14+
'!--',
15+
text('<!--', 0),
16+
[],
17+
[text(' it is comment ')],
18+
text('-->'),
19+
0,
20+
),
21+
text('\n-\n'),
22+
]);
23+
});
24+
});

0 commit comments

Comments
 (0)