})
})
+ // https://github.com/vuejs/docs/issues/2586
+ test('v-pre with half-open interpolation', () => {
+ const ast = baseParse(
+ `<div v-pre>
+ <span>{{ number </span>
+ <span>}}</span>
+ </div>
+ `
+ )
+ expect((ast.children[0] as ElementNode).children).toMatchObject([
+ {
+ type: NodeTypes.ELEMENT,
+ children: [{ type: NodeTypes.TEXT, content: `{{ number ` }]
+ },
+ {
+ type: NodeTypes.ELEMENT,
+ children: [{ type: NodeTypes.TEXT, content: `}}` }]
+ }
+ ])
+
+ const ast2 = baseParse(`<div v-pre><span>{{ number </span></div>`)
+ expect((ast2.children[0] as ElementNode).children).toMatchObject([
+ {
+ type: NodeTypes.ELEMENT,
+ children: [{ type: NodeTypes.TEXT, content: `{{ number ` }]
+ }
+ ])
+ })
+
test('self-closing v-pre', () => {
const ast = baseParse(
`<div v-pre/>\n<div :id="foo"><Comp/>{{ bar }}</div>`
loc: getLoc(start)
}
if (name === 'pre') {
- inVPre = true
+ inVPre = tokenizer.inVPre = true
currentVPreBoundary = currentOpenTag
// convert dirs before this one to attributes
const props = currentOpenTag!.props
inPre--
}
if (currentVPreBoundary === el) {
- inVPre = false
+ inVPre = tokenizer.inVPre = false
currentVPreBoundary = null
}
if (
public inRCDATA = false
/** For disabling RCDATA tags handling */
public inXML = false
+ /** For disabling interpolation parsing in v-pre */
+ public inVPre = false
/** Record newline positions for fast line / column calculation */
private newlines: number[] = []
this.sectionStart = this.index
} else if (!__BROWSER__ && c === CharCodes.Amp) {
this.startEntity()
- } else if (c === this.delimiterOpen[0]) {
+ } else if (!this.inVPre && c === this.delimiterOpen[0]) {
this.state = State.InterpolationOpen
this.delimiterIndex = 0
this.stateInterpolationOpen(c)