Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(runtime-core): unable to set object to dom props #1093

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
}
}