diff --git a/src/diff/index.js b/src/diff/index.js index 3ee1c9cd04..b154e085b0 100644 --- a/src/diff/index.js +++ b/src/diff/index.js @@ -294,9 +294,13 @@ function diffElementNodes( if (newVNode.type === null) { return document.createTextNode(newProps); } + dom = isSvg ? document.createElementNS('http://www.w3.org/2000/svg', newVNode.type) - : document.createElement(newVNode.type); + : document.createElement( + newVNode.type, + newProps.is && { is: newProps.is } + ); // we created a new parent, so none of the previously attached children can be reused: excessDomChildren = null; } diff --git a/test/browser/customBuiltInElements.test.js b/test/browser/customBuiltInElements.test.js new file mode 100644 index 0000000000..37b27d6c78 --- /dev/null +++ b/test/browser/customBuiltInElements.test.js @@ -0,0 +1,42 @@ +import { createElement, render, Component } from 'preact'; +import { setupScratch, teardown } from '../_util/helpers'; + +/** @jsx createElement */ + +describe('customised built-in elements', () => { + let scratch; + + beforeEach(() => { + scratch = setupScratch(); + }); + + afterEach(() => { + teardown(scratch); + }); + + it('should create built in elements correctly', () => { + class Foo extends Component { + constructor(props) { + super(props); + return true; + } + render() { + return
; + } + } + + const spy = sinon.spy(); + + class BuiltIn extends HTMLDivElement { + connectedCallback() { + spy(); + } + } + + customElements.define('built-in', BuiltIn, { extends: 'div' }); + + render(, scratch); + + expect(spy).to.have.been.calledOnce; + }); +});