'How to create registered html5 custom element with javascript with IS property and have it run connectedCallback() successfully
Let's say we have an html5 custom element that extends the HTMLAnchorElement and goes by the name 'custom-a', then we insert it directly in the html like this
<a href="" is="custom-a">Hello World</a>
as expected this will trigger the connectedCallback(), now how do I accomplish the same thing by creating and inserting the custom element via javascript, I tried:
<script>
let elem = document.createElement('a');
elem.setAttribute('is', 'custom-a');
document.body.appendChild(elem);
</script>
But connectedCallback() fails to run
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
