): void
insert(el: HostNode, parent: HostElement, anchor?: HostNode | null): void
remove(el: HostNode): void
- createElement(type: string, isSVG?: boolean): HostElement
+ createElement(
+ type: string,
+ isSVG?: boolean,
+ isCustomizedBuiltIn?: string
+ ): HostElement
createText(text: string): HostNode
createComment(text: string): HostNode
setText(node: HostNode, text: string): void
// exactly the same, and we can simply do a clone here.
el = vnode.el = hostCloneNode(vnode.el)
} else {
- el = vnode.el = hostCreateElement(vnode.type as string, isSVG)
+ el = vnode.el = hostCreateElement(
+ vnode.type as string,
+ isSVG,
+ props && props.is
+ )
// props
if (props) {
for (const key in props) {
--- /dev/null
+import { render, h } from '@vue/runtime-dom'
+
+describe('customimized built-in elements support', () => {
+ let createElement: jest.SpyInstance
+ afterEach(() => {
+ createElement.mockRestore()
+ })
+
+ test('should created element with is option', () => {
+ const root = document.createElement('div')
+ createElement = jest.spyOn(document, 'createElement')
+ render(h('button', { is: 'plastic-button' }), root)
+ expect(createElement.mock.calls[0]).toMatchObject([
+ 'button',
+ { is: 'plastic-button' }
+ ])
+ // should also render the attribute
+ expect(root.innerHTML).toBe(`<button is="plastic-button"></button>`)
+ })
+})
}
},
- createElement: (tag, isSVG): Element =>
- isSVG ? doc.createElementNS(svgNS, tag) : doc.createElement(tag),
+ createElement: (tag, isSVG, is): Element =>
+ isSVG
+ ? doc.createElementNS(svgNS, tag)
+ : doc.createElement(tag, is ? { is } : undefined),
createText: text => doc.createTextNode(text),