Sfoglia il codice sorgente

test for refactored component scope compilation

Evan You 11 anni fa
parent
commit
d0560e3a78

+ 2 - 1
test/unit/specs/directives/component_spec.js

@@ -148,7 +148,8 @@ if (_.inBrowser) {
         template: '<div v-component="test" v-show="ok">{{message}}</div>',
         components: {
           test: {
-            template: '<content></content> {{message}}',
+            template: '<div><content></content> {{message}}</div>',
+            replace: true,
             data: function () {
               return {
                 message: 'world'

+ 30 - 0
test/unit/specs/directives/repeat_spec.js

@@ -225,6 +225,36 @@ if (_.inBrowser) {
       expect(el.innerHTML).toBe(markup + '<!--v-repeat-->')
     })
 
+    it('component + parent directive + transclusion', function (done) {
+      var vm = new Vue({
+        el: el,
+        template: '<div v-repeat="list" v-component="test" v-class="cls">{{msg}}</div>',
+        data: {
+          cls: 'parent',
+          msg: 'hi',
+          list: [{a:1},{a:2},{a:3}]
+        },
+        components: {
+          test: {
+            replace: true,
+            template: '<div class="child">{{a}} <content></content></div>'
+          }
+        }
+      })
+      var markup = vm.list.map(function (item) {
+        return '<div class="child parent">' + item.a + ' hi</div>'
+      }).join('')
+      expect(el.innerHTML).toBe(markup + '<!--v-repeat-->')
+      vm.msg = 'ho'
+      markup = vm.list.map(function (item) {
+        return '<div class="child parent">' + item.a + ' ho</div>'
+      }).join('')
+      _.nextTick(function () {
+        expect(el.innerHTML).toBe(markup + '<!--v-repeat-->')
+        done()
+      })
+    })
+
     it('array filters', function (done) {
       var vm = new Vue({
         el: el,