-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Several questions about the "Initialisation order" section #1456
Comments
No apologies necessary, keep up the great feedback. The section is confusing partly because there are only a few guarantees we can give, and many mysteries. But your feedback is spot-on and we can definitely clarify many of these points. Broadly speaking, your interpretation is correct as I understand it. For any given element, the order is as listed. Local DOM init means, "local DOM children are created, their property values are set as specified in the template, and ready() has been called on them." In essence, it means, "the stuff we do before calling ready," so maybe we can just be clearer about what that is and drop it from this list.
As for light children, there are no guarantees at all, although broadly speaking you would expect them to be Fortunately, you can now use |
When you say:
Here, what do you mean by "These", and what do you mean by "them"?
(Except for elements created in a
Meaning that the an element E with children elements C1 C2 C3 might be attached to its parent P before C1, C2 and C3 are attached to E itself? |
For #1, by "these elements" and "them" I mean "dom-if or dom-repeat elements". The thing to remember is that the On the last comment--I'm not sure whether the actual attachment happens in a different order, or just the |
And about this one:
So if I have something like that:
And avatar-list has |
Correct. |
My attempt to amend the existing documentation. I tried to integrate everything we discussed, so that (hopefully) nobody wonders the same thing. I divided the issue in three different parts; I feel that this makes things clearer. I also made a distinction between initialisation order and initialisation timing. I would love to also have a section here that explains the practical implications of this. When does it really matter than a child's (Note that I tried my best to use american spellings, but UK/Aussie slip-ups might have happened :D (I'm Australian) Initialization order and timing {#initialization-order}The element's basic initialization order for a given element is:
Note that while the life cycle callbacks listed above will be called in the described order for any given element, the initialization timing between elements may vary depending on whether or not the Initialization timing for light DOM childrenAs far as initialization timing of light DOM children there are no guarantees at all, although broadly speaking you would expect them to be ready in document order, which means they'd be usually initialized after their parents. Of course, the user can add light children at any time. For example if you have something like this:
And Initialization timing for local DOM childrenLocal DOM children are created, their property values are set as specified in the template, and There are two caveats:
Initialization timing for siblingsThere are no guarantees with regard to initialization timing between sibling elements. This means that siblings may become For accessing sibling elements when an element initializes, you can call
I hope this helps... Merc. |
BTW I realise what I wrote is longer than the original version. As usual, if you think it's not up to standard or not usable, 10000% NOT hard feelings! |
Thanks Merc. I think I can use something like that, but I'd have to massage to fit the doc site style. If you're interested, you can open a PR and I'll walk you through the edits. Or I can do it. |
👍 This new explanation actually helped me quite a bit. You may want to change
to something which gives a brief ELI5 explanation of what local dom is, and then get into how it behaves.
|
💯 this thread is a great read :) |
Sorry for answering so late. My computer actually broke, and had to real with some interesting disaster recovery... |
Hi @mercmobily! Sorry to hear about your computer. I think the general structure is good, we need to make the language a little less chatty, but that's a detail. If you're up for it, please go ahead with the PR! I'm off work until the new year, so if you don't hear from me right away... I'm not neglecting you, but this eggnog's not going to drink itself. |
Hi, OK will do! Merc. On 24 December 2015 at 04:17, Arthur Evans [email protected] wrote:
|
Well I did: #1479 I guess this ticked could/should be closed? |
Hi, I'm looking for a way to ensure that the attached callback on child elements are called before the attached callback on the parent. Thanks, update: |
I have a few questions regarding the Initialisation order section.
dom-repeat
, etc) are set? Or all elements in the local DOM areready()
ed? Or... what do you mean exactly?Here, it looks like the calls above may be called in a different order. However, the next sentence:
Seems to focus on initialisation timing among parent/siblings, rather than initialisation order within an element. And it's talking specifically about light DOM...
The document then continues:
So, the order created -> ready -> attached is always observed... whereas factoryImpl and local DOM initialisation may happen anytime?
Does that mean that ready() is called on the host element before any local DOM children, but you cannot trust the light DOM children's ready() to be called after the host element's ready()?
Finally, the doc says:
Does that mean siblings within the light DOM? Or local DOM? Or either?
OK, I must admit I am totally confused by this section. Help :D
The main points are:
ready()
before its parent...I would do the following:
I am sorry, this ticket is confusing because I really haven't managed to make heads or tails of what exactly the issues are.
In the Migration guide, I read:
"A more complete solution is in progress. In the meantime, if you are using domReady in 1.0 you can replace it by using the async method inside your attached callback:"
Is there a ticket where this is being tackled? I'd love to have a look.
Sorry, as you can see I am going through the Polymer documentation, and... I guess that's what you get when you get somebody ever so slightly obsessive to go through things...
(Plus, it's not clear how an element would be able to know when all of its light DOM children are fully initialised!)
The text was updated successfully, but these errors were encountered: