Skip to content

Commit 95cd2bd

Browse files
committed
test v-model select with circular reference
1 parent e6f89c0 commit 95cd2bd

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

test/unit/features/directives/model-select.spec.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,4 +445,30 @@ describe('Directive v-model select', () => {
445445
done()
446446
}, 0)
447447
})
448+
449+
it('should work with option value that has circular reference', done => {
450+
const circular = {}
451+
circular.self = circular
452+
453+
const vm = new Vue({
454+
data: {
455+
test: 'b',
456+
circular
457+
},
458+
template:
459+
'<select v-model="test">' +
460+
'<option :value="circular">a</option>' +
461+
'<option>b</option>' +
462+
'<option>c</option>' +
463+
'</select>'
464+
}).$mount()
465+
document.body.appendChild(vm.$el)
466+
expect(vm.test).toBe('b')
467+
expect(vm.$el.value).toBe('b')
468+
expect(vm.$el.childNodes[1].selected).toBe(true)
469+
vm.test = circular
470+
waitForUpdate(function () {
471+
expect(vm.$el.childNodes[0].selected).toBe(true)
472+
}).then(done)
473+
})
448474
})

0 commit comments

Comments
 (0)