fix(parser): should reset inRCDATA state

This commit is contained in:
Evan You 2023-11-28 18:31:17 +08:00
parent 7d89887f71
commit ef97e8b07d
2 changed files with 7 additions and 0 deletions

View File

@ -1952,6 +1952,12 @@ describe('compiler: parse', () => {
}) })
}) })
// edge case found in vue-macros where the input is TS or JSX
test('should reset inRCDATA state', () => {
baseParse(`<Foo>`, { parseMode: 'sfc', onError() {} })
expect(() => baseParse(`{ foo }`)).not.toThrow()
})
describe('decodeEntities option', () => { describe('decodeEntities option', () => {
test('use decode by default', () => { test('use decode by default', () => {
const ast: any = baseParse('&gt;&lt;&amp;&apos;&quot;&foo;') const ast: any = baseParse('&gt;&lt;&amp;&apos;&quot;&foo;')

View File

@ -271,6 +271,7 @@ export default class Tokenizer {
this.sectionStart = 0 this.sectionStart = 0
this.index = 0 this.index = 0
this.baseState = State.Text this.baseState = State.Text
this.inRCDATA = false
this.currentSequence = undefined! this.currentSequence = undefined!
this.newlines.length = 0 this.newlines.length = 0
this.delimiterOpen = defaultDelimitersOpen this.delimiterOpen = defaultDelimitersOpen