I'm trying to get a customized built-in web component to work in codesandbox.io. This is the code:
class MyDiv extends HTMLDivElement {
constructor() {
super();
}
connectedCallback() {
this.innerHTML = "works!";
}
}
customElements.define("my-div", MyDiv, {extends: 'div'});
<div is="my-div"></div>
The error I'm getting:
Failed to construct 'HTMLDivElement': Please use the 'new' operator, this DOM object constructor cannot be called as a function.
Tested in Chrome 67, Arch Linux. Here's the link: https://codesandbox.io/s/yqln560jzj
It does work here in a snippet, and it also works on codepen: https://codepen.io/connexo/pen/ZjEbqo
What am I missing here?