You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We are running rarely into issues when the composite AMP elements have their build method called when their children list is in complete. E.g. an amp-carousel may have 10 slides total, but it's build is called only when its children reports only 2 subelements. A symptom of this problem can be seen in #983. To observe the issue, you can also see http://jsbin.com/folura/edit.
We currently use three signals to build most of these elements: attachedCallback, upgrade and DOMReady. We build as soon as at least one real child is available, assuming that all children are already there. This causes problems.
Thus, we have three options:
Defer building these elements until DOMReady
Build these elements as we do now, but further rely on mutation events to do additional incremental builds.
A compromise where we would proceed as currently, implement rebuildCallback and element visibility whitelisting as described below. But instead of using mutate events, we will simply wait for DOMReady to run rebuilds.
This will look as following:
We will call buildCallback in the element as we do today.
The element will do the initial build
The element will apply styling that will state: "display:none all my children except those whitelisted explicitly". E.g. .-amp-composite > *:not(.-amp-composite-allowed) {display: none}. This will ensure that newly added nodes do not show immediately and give the element chance to reconfigure them.
The element will also return the mutation config, e.g. {childList: true}. This way the element will say: "I'm built but I'm also interested in getting the following mutation events".
The runtime will subscribe via MutationObserver and will polyfill it partially where needed.
The runtime will mark an element that receives mutation events as "toRebuild"
In next cycle, the runtime will call the element's rebuildCallback method and reset "toRebuild" flag.
The text was updated successfully, but these errors were encountered:
We are running rarely into issues when the composite AMP elements have their build method called when their children list is in complete. E.g. an amp-carousel may have 10 slides total, but it's build is called only when its
children
reports only 2 subelements. A symptom of this problem can be seen in #983. To observe the issue, you can also see http://jsbin.com/folura/edit.We currently use three signals to build most of these elements: attachedCallback, upgrade and DOMReady. We build as soon as at least one real child is available, assuming that all children are already there. This causes problems.
Thus, we have three options:
rebuildCallback
and element visibility whitelisting as described below. But instead of using mutate events, we will simply wait for DOMReady to run rebuilds.This will look as following:
buildCallback
in the element as we do today..-amp-composite > *:not(.-amp-composite-allowed) {display: none}
. This will ensure that newly added nodes do not show immediately and give the element chance to reconfigure them.{childList: true}
. This way the element will say: "I'm built but I'm also interested in getting the following mutation events".rebuildCallback
method and reset "toRebuild" flag.The text was updated successfully, but these errors were encountered: