From eb95ff97b3214795352a857613b05d06d6495d7a Mon Sep 17 00:00:00 2001 From: Jason Yu Date: Fri, 1 May 2020 09:43:14 +0100 Subject: [PATCH] fix(runtime-core): unable to set object to dom props - Remove casting nullish values to '' --- packages/runtime-dom/__tests__/patchProps.spec.ts | 12 +++++++++++- packages/runtime-dom/src/modules/props.ts | 2 +- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/packages/runtime-dom/__tests__/patchProps.spec.ts b/packages/runtime-dom/__tests__/patchProps.spec.ts index ce30f91162f..7c82c41d8b0 100644 --- a/packages/runtime-dom/__tests__/patchProps.spec.ts +++ b/packages/runtime-dom/__tests__/patchProps.spec.ts @@ -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', () => { @@ -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 = { diff --git a/packages/runtime-dom/src/modules/props.ts b/packages/runtime-dom/src/modules/props.ts index 0b36578eb88..99eb51241cb 100644 --- a/packages/runtime-dom/src/modules/props.ts +++ b/packages/runtime-dom/src/modules/props.ts @@ -32,6 +32,6 @@ export function patchDOMProp( // e.g.