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

fix content transclusion with replace:true + block instance

Evan You 11 лет назад
Родитель
Сommit
8a2a7f372e
2 измененных файлов с 3 добавлено и 2 удалено
  1. 2 2
      src/compile/transclude.js
  2. 1 0
      test/unit/specs/compile/transclude_spec.js

+ 2 - 2
src/compile/transclude.js

@@ -44,7 +44,7 @@ function transcludeTemplate (el, options) {
     collectRawContent(el)
     if (options.replace) {
       if (frag.childNodes.length > 1) {
-        transcludeContent(_.toArray(frag.childNodes))
+        transcludeContent(frag)
         return frag
       } else {
         var replacer = frag.firstChild
@@ -133,7 +133,7 @@ var concat = [].concat
 function getOutlets (el) {
   return _.isArray(el)
     ? concat.apply([], el.map(getOutlets))
-    : el.nodeType === 1
+    : el.querySelectorAll
       ? _.toArray(el.querySelectorAll('content'))
       : []
 }

+ 1 - 0
test/unit/specs/compile/transclude_spec.js

@@ -87,6 +87,7 @@ if (_.inBrowser) {
     it('block instance content transclusion', function () {
       el.innerHTML = '<p>hi</p><span>ho</span>'
       options.template = '<div></div><content select="p"></content><content select="span"></content>'
+      options.replace = true
       var res = transclude(el, options)
       expect(res.firstChild.tagName).toBe('DIV')
       expect(res.childNodes[1].tagName).toBe('P')