Closed lukas-schardt closed 4 years ago
If you are trying to access the children of the current element inside the connected-Hook, the HTMLCollection will be empty.
connected
connected() { this._children = [ ...this.children ]; console.log(this._children, this.children ); }
But if we are requesting an animation frame it works and the array is not empty anymore
connected() { requestAnimationFrame(() => { this._children = [ ...this.children ]; console.log(this._children, this.children ); }); }
This occured due to early script execution time. It seems like the browser does not know the children of a custom element in the connectedCallback when the script is executed before the elements dom position.
If you are trying to access the children of the current element inside the
connected
-Hook, the HTMLCollection will be empty.But if we are requesting an animation frame it works and the array is not empty anymore