Custom elements v1 - can't get CE children in connectedCallback()
Reported by
cont...@julien-gras.fr,
Aug 22 2016
|
|||||
Issue description
UserAgent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.70 Safari/537.36
Steps to reproduce the problem:
- Case 1 : KO
#-- custom elements defintions --#
<elmt-container>
<div>1</div>
<elmt-test>2</elmt-test>
</elmt-container>
Result : i just get the first div when i call this.children in the connectedCallback of elmt-container.
JsFiddle: https://jsfiddle.net/mcd7bd82/ in canary
- Case 2 : OK
<elmt-container>
<div>1</div>
<elmt-test>2</elmt-test>
</elmt-container>
#-- custom elements defintions --#
result : i get all children when i call this.children in the connectedCallback of elmt-container.
JsFiddle: https://jsfiddle.net/4uw0a7yk/ in canary
What is the expected behavior?
It should return all children including CE and not only native elements.
What went wrong?
I think connectedCallback() is called too soon: before the nested CE are initialized ?
Did this work before? No
Chrome version: 54.0.2836.0 Channel: canary
OS Version: 10.0
Flash Version: Shockwave Flash 23.0 r0
,
Aug 23 2016
dominicc@ (or kojii@), could you triage this?
,
Aug 23 2016
Case 1 is what the spec defines as "create", and case 2 is "upgrade". For upgrade, I read the spec the same way as you. For case 1 (create, by the document parser), it reads to me that the Blink behavior matches to what the spec says, but I understand it's not very friendly, and I can't find good alternative web developers can take. Filed https://github.com/w3c/webcomponents/issues/551 for a spec discussion. Please point out if you see I read the spec incorrectly, or any other opinions, here or there.
,
Oct 12 2016
,
Oct 27 2016
It sounds like this is working as intended. In the future it may make sense to add more callbacks, etc. but the idea is that connected is not the single right place to poll the child list. It might be useful as part of a lazy strategy, in combination with MutationObservers, requestAnimationFrame, etc. |
|||||
►
Sign in to add a comment |
|||||
Comment 1 by junov@chromium.org
, Aug 22 2016