Skip to content

Commit a88295d

Browse files
authoredJun 6, 2024··
fix(custom-elements): compatibility of createElement in older versions of Chrome (#9615)
close #9614
1 parent d04417d commit a88295d

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed
 

‎packages/runtime-dom/__tests__/nodeOps.spec.ts

+14
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,20 @@ describe('runtime-dom: node-ops', () => {
1818
expect(option2.selected).toBe(true)
1919
})
2020

21+
test('create custom elements', () => {
22+
const spyCreateElement = vi.spyOn(document, 'createElement')
23+
24+
nodeOps.createElement('custom-element')
25+
expect(spyCreateElement).toHaveBeenLastCalledWith('custom-element')
26+
27+
nodeOps.createElement('custom-element', undefined, 'li')
28+
expect(spyCreateElement).toHaveBeenLastCalledWith('custom-element', {
29+
is: 'li',
30+
})
31+
32+
spyCreateElement.mockClear()
33+
})
34+
2135
describe('insertStaticContent', () => {
2236
test('fresh insertion', () => {
2337
const content = `<div>one</div><div>two</div>three`

‎packages/runtime-dom/src/nodeOps.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ export const nodeOps: Omit<RendererOptions<Node, Element>, 'patchProp'> = {
2525
? doc.createElementNS(svgNS, tag)
2626
: namespace === 'mathml'
2727
? doc.createElementNS(mathmlNS, tag)
28-
: doc.createElement(tag, is ? { is } : undefined)
28+
: is
29+
? doc.createElement(tag, { is })
30+
: doc.createElement(tag)
2931

3032
if (tag === 'select' && props && props.multiple != null) {
3133
;(el as HTMLSelectElement).setAttribute('multiple', props.multiple)

0 commit comments

Comments
 (0)
Please sign in to comment.