fix(sfc): treat custom block content as raw text

This commit is contained in:
Evan You
2019-12-22 21:09:39 -05:00
parent 90ddb7c260
commit d6275a3c31
4 changed files with 25 additions and 5 deletions

View File

@@ -2,7 +2,8 @@ import {
NodeTypes,
ElementNode,
SourceLocation,
CompilerError
CompilerError,
TextModes
} from '@vue/compiler-core'
import { RawSourceMap, SourceMapGenerator } from 'source-map'
import LRUCache from 'lru-cache'
@@ -89,6 +90,15 @@ export function parse(
isNativeTag: () => true,
// preserve all whitespaces
isPreTag: () => true,
getTextMode: (tag, _ns, parent) => {
// all top level elements except <template> are parsed as raw text
// containers
if (!parent && tag !== 'template') {
return TextModes.RAWTEXT
} else {
return TextModes.DATA
}
},
onError: e => {
errors.push(e)
}