Evan You 12 лет назад
Родитель
Сommit
55d8dbea74
2 измененных файлов с 12 добавлено и 7 удалено
  1. 12 2
      src/compiler.js
  2. 0 5
      src/directives/model.js

+ 12 - 2
src/compiler.js

@@ -368,6 +368,16 @@ CompilerProto.checkPriorityDir = function (dirname, node, root) {
  */
 CompilerProto.compileElement = function (node, root) {
 
+    // textarea is pretty annoying
+    // because its value creates childNodes which
+    // we don't want to compile.
+    if (node.tagName === 'TEXTAREA' && node.value) {
+        node.value = this.eval(node.value)
+    }
+
+    // only compile if this element has attributes
+    // or its tagName contains a hyphen (which means it could
+    // potentially be a custom element)
     if (node.hasAttributes() || node.tagName.indexOf('-') > -1) {
 
         // skip anything with v-pre
@@ -442,7 +452,7 @@ CompilerProto.compileElement = function (node, root) {
     }
 
     // recursively compile childNodes
-    if (node.hasChildNodes() && node.tagName !== 'TEXTAREA') {
+    if (node.hasChildNodes()) {
         slice.call(node.childNodes).forEach(this.compile, this)
     }
 }
@@ -465,7 +475,7 @@ CompilerProto.compileTextNode = function (node) {
             if (token.key.charAt(0) === '>') { // a partial
                 el = document.createComment('ref')
                 directive = Directive.parse('partial', token.key.slice(1), this, el)
-            } else { // a real binding
+            } else {
                 if (!token.html) { // text binding
                     el = document.createTextNode('')
                     directive = Directive.parse('text', token.key, this, el)

+ 0 - 5
src/directives/model.js

@@ -27,11 +27,6 @@ module.exports = {
         self.lock = false
         self.ownerVM = self.binding.compiler.vm
 
-        // textarea
-        if (tag === 'TEXTAREA' && el.value) {
-            el.value = self.compiler.eval(el.value)
-        }
-
         // determine what event to listen to
         self.event =
             (self.compiler.options.lazy ||