@@ -1,7 +1,10 @@
|
||||
import { patchProp } from '../src/patchProp'
|
||||
import { render, h } from '../src'
|
||||
import { mockWarn } from '@vue/shared'
|
||||
|
||||
describe('runtime-dom: props patching', () => {
|
||||
mockWarn()
|
||||
|
||||
test('basic', () => {
|
||||
const el = document.createElement('div')
|
||||
patchProp(el, 'id', null, 'foo')
|
||||
@@ -92,4 +95,16 @@ describe('runtime-dom: props patching', () => {
|
||||
patchProp(el, 'srcObject', null, null)
|
||||
expect(el.srcObject).toBe(intiialValue)
|
||||
})
|
||||
|
||||
test('catch and warn prop set TypeError', () => {
|
||||
const el = document.createElement('div')
|
||||
Object.defineProperty(el, 'someProp', {
|
||||
set() {
|
||||
throw new TypeError('Invalid type')
|
||||
}
|
||||
})
|
||||
patchProp(el, 'someProp', null, 'foo')
|
||||
|
||||
expect(`Failed setting prop "someProp" on <div>`).toHaveBeenWarnedLast()
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user