فهرست منبع

add test case for container/replacer attrs with same name

Evan You 11 سال پیش
والد
کامیت
4c25d1eb03
1فایلهای تغییر یافته به همراه28 افزوده شده و 0 حذف شده
  1. 28 0
      test/unit/specs/compiler/compile_spec.js

+ 28 - 0
test/unit/specs/compiler/compile_spec.js

@@ -242,5 +242,33 @@ if (_.inBrowser) {
       })
       })
     })
     })
 
 
+    it('should handle container/replacer directives with same name', function () {
+      var parentSpy = jasmine.createSpy()
+      var childSpy = jasmine.createSpy()
+      vm = new Vue({
+        el: el,
+        template:
+          '<div v-component="a" class="a" v-on="click:test(1)"></div>',
+        methods: {
+          test: parentSpy
+        },
+        components: {
+          a: {
+            template: '<div class="b" v-on="click:test(2)"></div>',
+            replace: true,
+            methods: {
+              test: childSpy
+            }
+          }
+        }
+      })
+      expect(vm.$el.firstChild.className).toBe('b a')
+      var e = document.createEvent('HTMLEvents')
+      e.initEvent('click', true, true)
+      vm.$el.firstChild.dispatchEvent(e)
+      expect(parentSpy).toHaveBeenCalledWith(1)
+      expect(childSpy).toHaveBeenCalledWith(2)
+    })
+
   })
   })
 }
 }