diff --git a/lib/elements/dom-if.html b/lib/elements/dom-if.html index 842e5a6593..be98f7a2ab 100644 --- a/lib/elements/dom-if.html +++ b/lib/elements/dom-if.html @@ -204,7 +204,7 @@ } if (!this.__instance) { this.__instance = new this.__ctor(); - parentNode.insertBefore(this.__instance.root, this); + this.__instance.insertBefore(parentNode, this); } else { this.__syncHostProperties(); let c$ = this.__instance.children; diff --git a/lib/elements/dom-repeat.html b/lib/elements/dom-repeat.html index 0b7ee3f5f3..fffc5ecf06 100644 --- a/lib/elements/dom-repeat.html +++ b/lib/elements/dom-repeat.html @@ -580,7 +580,7 @@ } let beforeRow = this.__instances[instIdx + 1]; let beforeNode = beforeRow ? beforeRow.children[0] : this; - this.parentNode.insertBefore(inst.root, beforeNode); + inst.insertBefore(this.parentNode, this); this.__instances[instIdx] = inst; return inst; } diff --git a/lib/utils/templatize.html b/lib/utils/templatize.html index 051aca976c..75347b783d 100644 --- a/lib/utils/templatize.html +++ b/lib/utils/templatize.html @@ -54,12 +54,6 @@ if (this.__templatizeOwner.__hideTemplateChildren__) { this._showHideChildren(true); } - // Flush props only when props are passed if instance props exist - // or when there isn't instance props. - let options = this.__templatizeOptions; - if ((props && options.instanceProps) || !options.instanceProps) { - this._flushProperties(); - } } /** * @private @@ -77,6 +71,16 @@ this._setPendingProperty(hprop, this.__dataHost['_host_' + hprop]); } } + /** + Inserts the templatized dom into the given `parentNode` before + `refNode`. + @param {Node} parentNode node into which to insert dom + @param {Node} refNode node before which to insert dom + */ + insertBefore(parentNode, refNode) { + parentNode.insertBefore(this.root, refNode); + this._flushProperties(); + } /** * Forwards a host property to this instance. This method should be * called on instances from the `options.forwardHostProp` callback diff --git a/test/smoke/ready-order.html b/test/smoke/ready-order.html new file mode 100644 index 0000000000..3fc55bccfa --- /dev/null +++ b/test/smoke/ready-order.html @@ -0,0 +1,72 @@ + + + + + + + + + + + + + + + + + + + + + + + + +