New issue
Advanced search Search tips

Issue 710122 link

Starred by 1 user

Issue metadata

Status: WontFix
Owner: ----
Closed: Apr 2017
EstimatedDays: ----
NextAction: ----
OS: Linux
Pri: 2
Type: Bug-Regression



Sign in to add a comment

children and content inconsistency in connectedCallback

Reported by mr.a...@gmail.com, Apr 10 2017

Issue description

UserAgent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.54 Safari/537.36

Steps to reproduce the problem:
1. Create a custom element
2. Add a connectedCallback that accesses and/or changes the content of the custom element
3. Run the code

What is the expected behavior?
The attached test case should produce "HelloWorld"

What went wrong?
The textContent is set to "WorldHello"

Did this work before? Yes Custom Elements v0

Does this work in other browsers? N/A

Chrome version: 58.0.3029.54  Channel: beta
OS Version: 3.16.0-4-amd64 #1 SMP Debian 3.16.36-1+deb8u2 (2016-10-19) x86_64 GNU/Linux
Flash Version: 

I don't even know if this is a bug.
It might as well be unexpected or not well-documented behaviour.
 
wat.html
235 bytes View Download
Status: WontFix (was: Unconfirmed)
This is working as intended. The connectedCallback is called the moment the element is connected, which happens when its start tag opens. We then later go through and add children to it, but that happens after it's connected.

If you want to run code after children are added, use a MutationObserver to wait for children.

Comment 2 by mr.a...@gmail.com, Apr 10 2017

Right, that clarifies that. In which case we need to be communicating it better somehow. I wasn't the only one surprised by this, even though it makes sense (as pointed out by Benjamin Sittler in the Chromium Slack).

Sign in to add a comment