Skip to content

Commit

Permalink
fix(runtime-core): unable to set object to dom props
Browse files Browse the repository at this point in the history
- Remove casting nullish values to ''
  • Loading branch information
Jason Yu committed May 1, 2020
1 parent a5bb1d0 commit eb95ff9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
12 changes: 11 additions & 1 deletion packages/runtime-dom/__tests__/patchProps.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ describe('runtime-dom: props patching', () => {
patchProp(el, 'id', null, 'foo')
expect(el.id).toBe('foo')
patchProp(el, 'id', null, null)
expect(el.id).toBe('')
expect(el.id).toBe('null')
})

test('value', () => {
Expand All @@ -30,6 +30,16 @@ describe('runtime-dom: props patching', () => {
expect(el.multiple).toBe(false)
})

// #1049
test('object prop', () => {
const el = document.createElement('video')
const object = {}
const set = jest.fn()
Object.defineProperty(el, 'srcObject', { enumerable: true, set })
patchProp(el, 'srcObject', null, object)
expect(set).toHaveBeenCalledWith(object)
})

test('innerHTML unmount prev children', () => {
const fn = jest.fn()
const comp = {
Expand Down
2 changes: 1 addition & 1 deletion packages/runtime-dom/src/modules/props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ export function patchDOMProp(
// e.g. <select multiple> compiles to { multiple: '' }
el[key] = true
} else {
el[key] = value == null ? '' : value
el[key] = value
}
}

0 comments on commit eb95ff9

Please sign in to comment.