mirror of
https://github.com/vuejs/vue.git
synced 2024-11-22 04:39:46 +00:00
handle template edge cases
This commit is contained in:
parent
448f3a6a78
commit
d04dbab15e
@ -13,7 +13,7 @@ const onRE = /^@|^v-on:/
|
||||
const mustUsePropsRE = /^(value|selected|checked|muted)$/
|
||||
|
||||
export function generate (ast) {
|
||||
const code = genElement(ast)
|
||||
const code = ast ? genElement(ast) : '__h__("div")'
|
||||
return new Function(`with (this) { return ${code}}`)
|
||||
}
|
||||
|
||||
|
@ -23,9 +23,9 @@ export function parse (html, preserveWhiteSpace) {
|
||||
}
|
||||
if (!root) {
|
||||
root = element
|
||||
} else if (!stack.length) {
|
||||
} else if (process.env.NODE_ENV !== 'production' && !stack.length) {
|
||||
console.error(
|
||||
'Component template should contain ony one root element:\n\n' + html
|
||||
'Component template should contain exactly one root element:\n\n' + html
|
||||
)
|
||||
}
|
||||
if (currentParent) {
|
||||
@ -41,7 +41,14 @@ export function parse (html, preserveWhiteSpace) {
|
||||
currentParent = stack[stack.length - 1]
|
||||
},
|
||||
chars (text) {
|
||||
if (!currentParent) return
|
||||
if (!currentParent) {
|
||||
if (process.env.NODE_ENV !== 'production' && !root) {
|
||||
console.error(
|
||||
'Component template should contain exactly one root element:\n\n' + html
|
||||
)
|
||||
}
|
||||
return
|
||||
}
|
||||
text = currentParent.tag === 'pre'
|
||||
? decodeHTML(text)
|
||||
: text.trim()
|
||||
|
Loading…
Reference in New Issue
Block a user