Просмотр исходного кода

fix compile for <template> tags

Evan You 11 лет назад
Родитель
Сommit
abe164fb76
2 измененных файлов с 7 добавлено и 6 удалено
  1. 7 0
      src/compile/compile.js
  2. 0 6
      src/compile/transclude.js

+ 7 - 0
src/compile/compile.js

@@ -19,6 +19,13 @@ function noop () {}
  */
 
 var compile = module.exports = function (el, options) {
+  // for template tags, what we want is its content as
+  // a documentFragment (for block instances)
+  if (el.tagName === 'TEMPLATE') {
+    el = el.content instanceof DocumentFragment
+      ? el.content
+      : templateParser.parse(el.innerHTML)
+  }
   var nodeLinkFn = el instanceof DocumentFragment
     ? null
     : compileNode(el, options)

+ 0 - 6
src/compile/transclude.js

@@ -23,12 +23,6 @@ var transclude = module.exports = function (el, options) {
   }
   if (el instanceof DocumentFragment) {
     return transcludeBlock(el)
-  } else if (el.tagName === 'TEMPLATE') {
-    if (el.content instanceof DocumentFragment) {
-      return transclude(el.content)
-    } else {
-      return transclude(templateParser.parse(el))
-    }
   } else if (options.template) {
     return transcludeTemplate(el, options)
   } else {