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

fix v-bind.prop parse (fix #4432) (#4435)

* reset isProp value

* add test case

* update test case

* fix typo
chengchao 9 лет назад
Родитель
Сommit
183bd43c3e
2 измененных файлов с 13 добавлено и 0 удалено
  1. 1 0
      src/compiler/parser/index.js
  2. 12 0
      test/unit/features/directives/bind.spec.js

+ 1 - 0
src/compiler/parser/index.js

@@ -414,6 +414,7 @@ function processAttrs (el) {
       if (bindRE.test(name)) { // v-bind
         name = name.replace(bindRE, '')
         value = parseFilters(value)
+        isProp = false
         if (modifiers) {
           if (modifiers.prop) {
             isProp = true

+ 12 - 0
test/unit/features/directives/bind.spec.js

@@ -121,6 +121,18 @@ describe('Directive v-bind', () => {
     expect(vm.$el.children[1].innerHTML).toBe('<span>qux</span>')
   })
 
+  it('.prop modifier with normal attribute binding', () => {
+    const vm = new Vue({
+      template: '<input :some.prop="some" :id="id">',
+      data: {
+        some: 'hello',
+        id: false
+      }
+    }).$mount()
+    expect(vm.$el.some).toBe('hello')
+    expect(vm.$el.getAttribute('id')).toBe(null)
+  })
+
   it('.camel modifier', () => {
     const vm = new Vue({
       template: '<svg :view-box.camel="viewBox"></svg>',