Przeglądaj źródła

test v-model select with circular reference

Evan You 9 lat temu
rodzic
commit
95cd2bd7fa
1 zmienionych plików z 26 dodań i 0 usunięć
  1. 26 0
      test/unit/features/directives/model-select.spec.js

+ 26 - 0
test/unit/features/directives/model-select.spec.js

@@ -445,4 +445,30 @@ describe('Directive v-model select', () => {
       done()
     }, 0)
   })
+
+  it('should work with option value that has circular reference', done => {
+    const circular = {}
+    circular.self = circular
+
+    const vm = new Vue({
+      data: {
+        test: 'b',
+        circular
+      },
+      template:
+        '<select v-model="test">' +
+          '<option :value="circular">a</option>' +
+          '<option>b</option>' +
+          '<option>c</option>' +
+        '</select>'
+    }).$mount()
+    document.body.appendChild(vm.$el)
+    expect(vm.test).toBe('b')
+    expect(vm.$el.value).toBe('b')
+    expect(vm.$el.childNodes[1].selected).toBe(true)
+    vm.test = circular
+    waitForUpdate(function () {
+      expect(vm.$el.childNodes[0].selected).toBe(true)
+    }).then(done)
+  })
 })