|
@@ -37,16 +37,17 @@ const svgMap = {
|
|
|
*/
|
|
*/
|
|
|
|
|
|
|
|
export function parse (template, preserveWhitespace) {
|
|
export function parse (template, preserveWhitespace) {
|
|
|
|
|
+ const stack = []
|
|
|
let root
|
|
let root
|
|
|
let currentParent
|
|
let currentParent
|
|
|
- let stack = []
|
|
|
|
|
let inSvg = false
|
|
let inSvg = false
|
|
|
let svgIndex = -1
|
|
let svgIndex = -1
|
|
|
let warned = false
|
|
let warned = false
|
|
|
parseHTML(template, {
|
|
parseHTML(template, {
|
|
|
html5: true,
|
|
html5: true,
|
|
|
|
|
+
|
|
|
start (tag, attrs, unary) {
|
|
start (tag, attrs, unary) {
|
|
|
- let element = {
|
|
|
|
|
|
|
+ const element = {
|
|
|
tag,
|
|
tag,
|
|
|
plain: !attrs.length,
|
|
plain: !attrs.length,
|
|
|
attrsList: attrs,
|
|
attrsList: attrs,
|
|
@@ -89,6 +90,7 @@ export function parse (template, preserveWhitespace) {
|
|
|
stack.push(element)
|
|
stack.push(element)
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
|
|
+
|
|
|
end () {
|
|
end () {
|
|
|
stack.length -= 1
|
|
stack.length -= 1
|
|
|
currentParent = stack[stack.length - 1]
|
|
currentParent = stack[stack.length - 1]
|
|
@@ -97,6 +99,7 @@ export function parse (template, preserveWhitespace) {
|
|
|
svgIndex = -1
|
|
svgIndex = -1
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
|
|
+
|
|
|
chars (text) {
|
|
chars (text) {
|
|
|
if (!currentParent) {
|
|
if (!currentParent) {
|
|
|
if (process.env.NODE_ENV !== 'production' && !warned) {
|
|
if (process.env.NODE_ENV !== 'production' && !warned) {
|
|
@@ -107,23 +110,13 @@ export function parse (template, preserveWhitespace) {
|
|
|
}
|
|
}
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
- text = currentParent.tag === 'pre'
|
|
|
|
|
|
|
+ text = currentParent.tag === 'pre' || text.trim()
|
|
|
? decodeHTML(text)
|
|
? decodeHTML(text)
|
|
|
- : text.trim()
|
|
|
|
|
- ? decodeHTML(text)
|
|
|
|
|
- : preserveWhitespace
|
|
|
|
|
- ? ' '
|
|
|
|
|
- : null
|
|
|
|
|
|
|
+ : preserveWhitespace ? ' ' : null
|
|
|
if (text) {
|
|
if (text) {
|
|
|
- if (text !== ' ') {
|
|
|
|
|
- let expression = parseText(text)
|
|
|
|
|
- if (expression) {
|
|
|
|
|
- currentParent.children.push({
|
|
|
|
|
- expression
|
|
|
|
|
- })
|
|
|
|
|
- } else {
|
|
|
|
|
- currentParent.children.push({ text })
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ let expression
|
|
|
|
|
+ if (text !== ' ' && (expression = parseText(text))) {
|
|
|
|
|
+ currentParent.children.push({ expression })
|
|
|
} else {
|
|
} else {
|
|
|
currentParent.children.push({ text })
|
|
currentParent.children.push({ text })
|
|
|
}
|
|
}
|