]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
fix(parser): should reset inRCDATA state
authorEvan You <yyx990803@gmail.com>
Tue, 28 Nov 2023 10:31:17 +0000 (18:31 +0800)
committerEvan You <yyx990803@gmail.com>
Tue, 28 Nov 2023 10:31:17 +0000 (18:31 +0800)
packages/compiler-core/__tests__/parse.spec.ts
packages/compiler-core/src/tokenizer.ts

index a116d22c148c9c5123c2f4120ffb94ea149f7178..4e6c80b38e0d999005ea5484a053f2c89c4ad953 100644 (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', () => {
     test('use decode by default', () => {
       const ast: any = baseParse('&gt;&lt;&amp;&apos;&quot;&foo;')
index 3a25c1c2d309a3a299701f8b2080eda6b8b1ec08..ea6d0592e0a804341579491d70e1620fab30e160 100644 (file)
@@ -271,6 +271,7 @@ export default class Tokenizer {
     this.sectionStart = 0
     this.index = 0
     this.baseState = State.Text
+    this.inRCDATA = false
     this.currentSequence = undefined!
     this.newlines.length = 0
     this.delimiterOpen = defaultDelimitersOpen