diff --git a/packages/runtime-dom/__tests__/nodeOps.spec.ts b/packages/runtime-dom/__tests__/nodeOps.spec.ts index 2573974c955..f1cba04de56 100644 --- a/packages/runtime-dom/__tests__/nodeOps.spec.ts +++ b/packages/runtime-dom/__tests__/nodeOps.spec.ts @@ -17,6 +17,20 @@ describe('runtime-dom: node-ops', () => { expect(option2.selected).toBe(true) }) + test('create custom elements', () => { + const spyCreateElement = vi.spyOn(document, 'createElement') + + nodeOps.createElement('custom-element', false) + expect(spyCreateElement).toHaveBeenLastCalledWith('custom-element') + + nodeOps.createElement('custom-element', false, 'li') + expect(spyCreateElement).toHaveBeenLastCalledWith('custom-element', { + is: 'li' + }) + + spyCreateElement.mockClear() + }) + describe('insertStaticContent', () => { test('fresh insertion', () => { const content = `
one
two
three` diff --git a/packages/runtime-dom/src/nodeOps.ts b/packages/runtime-dom/src/nodeOps.ts index daf56fc6f3a..7afed27d9ce 100644 --- a/packages/runtime-dom/src/nodeOps.ts +++ b/packages/runtime-dom/src/nodeOps.ts @@ -21,7 +21,9 @@ export const nodeOps: Omit, 'patchProp'> = { createElement: (tag, isSVG, is, props): Element => { const el = isSVG ? doc.createElementNS(svgNS, tag) - : doc.createElement(tag, is ? { is } : undefined) + : is + ? doc.createElement(tag, { is }) + : doc.createElement(tag) if (tag === 'select' && props && props.multiple != null) { ;(el as HTMLSelectElement).setAttribute('multiple', props.multiple)