Skip to content

Commit 6cd82b5

Browse files
committed
skip empty TextNode early in compilation
1 parent 6c84105 commit 6cd82b5

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/compiler/compile.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,15 +94,17 @@ module.exports = function compile (el, options, partial, asParent) {
9494
* @param {Node} node
9595
* @param {Object} options
9696
* @param {Boolean} asParent
97-
* @return {Function|undefined}
97+
* @return {Function|null}
9898
*/
9999

100100
function compileNode (node, options, asParent) {
101101
var type = node.nodeType
102102
if (type === 1 && node.tagName !== 'SCRIPT') {
103103
return compileElement(node, options, asParent)
104-
} else if (type === 3 && config.interpolate) {
104+
} else if (type === 3 && config.interpolate && node.data.trim()) {
105105
return compileTextNode(node, options)
106+
} else {
107+
return null
106108
}
107109
}
108110

@@ -190,7 +192,7 @@ function makeDirectivesLinkFn (directives) {
190192
*/
191193

192194
function compileTextNode (node, options) {
193-
var tokens = textParser.parse(node.nodeValue)
195+
var tokens = textParser.parse(node.data)
194196
if (!tokens) {
195197
return null
196198
}
@@ -263,7 +265,7 @@ function makeTextNodeLinkFn (tokens, frag) {
263265
if (token.html) {
264266
_.replace(node, templateParser.parse(value, true))
265267
} else {
266-
node.nodeValue = value
268+
node.data = value
267269
}
268270
} else {
269271
vm._bindDir(token.type, node,

0 commit comments

Comments
 (0)