@@ -2691,17 +2691,24 @@ export const PropertyEffects = dedupingMixin(superClass => {
26912691 }
26922692 if ( instanceBinding ) {
26932693 // For instance-time binding, create instance of template metadata
2694- // and link into list of templates if necessary
2694+ // and link into tree of templates if necessary
26952695 templateInfo = /** @type {!TemplateInfo } */ ( Object . create ( templateInfo ) ) ;
26962696 templateInfo . wasPreBound = wasPreBound ;
26972697 if ( ! this . __templateInfo ) {
26982698 // Set the info to the root of the tree
26992699 this . __templateInfo = templateInfo ;
27002700 } else {
27012701 // Append this template info onto the end of its parent template's
2702- // nested template list; if this template was not nested in another
2702+ // list, which will determine the tree structure via which property
2703+ // effects are run; if this template was not nested in another
27032704 // template, use the root template (the first stamped one) as the
2704- // parent
2705+ // parent. Note, `parent` is the `templateInfo` instance for this
2706+ // template's containing template, which was set up in
2707+ // `applyTemplateContent`. While a given template's `parent` is
2708+ // given, it is only added to the parent list at the point that it is
2709+ // being bound, since a template may or may not ever be stamped, and
2710+ // may be stamped more than once (in which case it will be in the
2711+ // tree more than once).
27052712 const parent = templateInfo . parent || this . __templateInfo ;
27062713 const previous = parent . lastChild ;
27072714 parent . lastChild = templateInfo ;
@@ -2800,7 +2807,10 @@ export const PropertyEffects = dedupingMixin(superClass => {
28002807 * @protected
28012808 */
28022809 _removeBoundDom ( dom ) {
2803- // Unlink template info
2810+ // Unlink template info; Note that while the child is unlinked from its
2811+ // parent list, a template's `parent` reference is never removed, since
2812+ // this is is determined by the tree structure and applied at
2813+ // `applyTemplateContent` time.
28042814 let templateInfo = dom . templateInfo ;
28052815 const { previousSibling, nextSibling, parent} = templateInfo ;
28062816 if ( previousSibling ) {
@@ -2955,19 +2965,31 @@ export const PropertyEffects = dedupingMixin(superClass => {
29552965 if ( removeNestedTemplates && ( isDomIf || isDomRepeat ) ) {
29562966 parent . removeChild ( node ) ;
29572967 nodeInfo . parentInfo . templateInfo = nestedTemplateInfo ;
2968+ // Ensure the parent dom-if/repeat is noted since it now has bindings;
2969+ // it may not have been if it did not have its own bindings
29582970 nodeInfo = nodeInfo . parentInfo ;
29592971 nodeInfo . noted = true ;
29602972 noted = false ;
29612973 }
29622974 // Merge host props into outer template and add bindings
29632975 let hostProps = nestedTemplateInfo . hostProps ;
29642976 if ( fastDomIf && isDomIf ) {
2977+ // `fastDomIf` mode uses runtime-template stamping to add accessors/
2978+ // effects to properties used in its template; as such we don't need to
2979+ // tax the host element with `_host_` bindings for the `dom-if`.
2980+ // However, in the event it is nested in a `dom-repeat`, it is still
2981+ // important that its host properties are added to the
2982+ // TemplateInstance's `hostProps` so that they are forwarded to the
2983+ // TemplateInstance.
29652984 if ( hostProps ) {
2985+ templateInfo . hostProps =
2986+ Object . assign ( templateInfo . hostProps || { } , hostProps ) ;
2987+ // Ensure the dom-if is noted so that it has a __dataHost, since
2988+ // `fastDomIf` uses the host for runtime template stamping; note this
2989+ // was already ensured above in the `removeNestedTemplates` case
29662990 if ( ! removeNestedTemplates ) {
29672991 nodeInfo . parentInfo . noted = true ;
29682992 }
2969- templateInfo . hostProps =
2970- Object . assign ( templateInfo . hostProps || { } , hostProps ) ;
29712993 }
29722994 } else {
29732995 let mode = '{' ;
0 commit comments