Open moepnse opened 3 months ago
Here is an equivalent example written in JavaScript that behaves as expected.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script type="text/javascript">
window.onload = function() {
class FooBar extends HTMLElement {
constructor(){
super();
this.shadow = this.attachShadow({ mode: 'open' })
}
connectedCallback() {
for (var i = 0; i < this.childNodes.length; i++) {
console.debug(this.childNodes[i]);
}
}
}
customElements.define('foo-bar', FooBar);
class UIIcon extends HTMLElement {
constructor(){
super();
this.shadow = this.attachShadow({ mode: 'open' })
}
}
customElements.define('ui-icon', UIIcon);
}
</script>
</head>
<body>
<foo-bar>
<h1>Test</h1>
<ui-icon></ui-icon>
</foo-bar>
</body>
Hello !
In _append_childs()
it seems that root.appendChild(child)
removes the child from self.childNodes
(I didn't test but it's probably the same in Javascript) ; if you remove it, the 5 child nodes are printed.
I think the problem can be solved by replacing for child in self.childNodes:
by for child in list(self.childNodes):
Hi!
If
self._childs_root
is a shadow DOM, then only text nodes are returned when iterating overself.childNodes
. A default slot is missing on purpose.I tried the same with JavaScript in the developer console and it returns every node inside the web component. Is this a bug or am I missing something?
Thanks in advance!