JSFiddle - React, Tailwind, and code Playground
How to avoid triggering element.attached before it's ready
by JakobJingleheimer
HTML
<div id="container"></div>
JavaScript
var container$ = document.getElementById('container');
var frag = document.createDocumentFragment();
var proto = Object.create(HTMLElement.prototype);
proto.attachedCallback = function() {
console.log(this.parentNode.children);
}
document.registerElement('my-foo', {
prototype: proto
});
var foo1 = document.createElement('my-foo');
foo1.title = "foo 1";
var foo2 = document.createElement('my-foo');
foo1.title = "foo 2";
frag.appendChild(foo1);
frag.appendChild(foo2);
container$.appendChild(frag);