Skip to content

Commit a0a619f

Browse files
committed
fix sfc parser hanging on trailing ill-formatted brackets (fix vue-loader/#628)
1 parent bf1f5f1 commit a0a619f

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/compiler/parser/html-parser.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,8 @@ export function parseHTML (html, options) {
168168
parseEndTag(stackedTag, index - endTagLength, index)
169169
}
170170

171-
if (html === last && options.chars) {
172-
options.chars(html)
171+
if (html === last) {
172+
options.chars && options.chars(html)
173173
break
174174
}
175175
}

test/unit/modules/sfc/sfc-parser.spec.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,4 +150,9 @@ describe('Single File Component parser', () => {
150150
const res = parseComponent(`<template>${raw}</template>`)
151151
expect(res.template.content.trim()).toBe(raw)
152152
})
153+
154+
it('should not hang on trailing text', () => {
155+
const res = parseComponent(`<template>hi</`)
156+
expect(res.template.content).toBe('hi')
157+
})
153158
})

0 commit comments

Comments
 (0)