diff --git a/iron-list.html b/iron-list.html index 49797beb..27102e72 100644 --- a/iron-list.html +++ b/iron-list.html @@ -584,6 +584,13 @@ return size - this._viewportHeight; }, + /** + * The parent node for the _userTemplate. + */ + get _itemsParent() { + return Polymer.dom(Polymer.dom(this._userTemplate).parentNode); + }, + /** * The maximum scroll top value. */ @@ -919,7 +926,7 @@ // First element child is item; Safari doesn't support children[0] // on a doc fragment. physicalItems[i] = inst.root.querySelector('*'); - Polymer.dom(this).appendChild(inst.root); + this._itemsParent.appendChild(inst.root); } return physicalItems; }, @@ -1028,7 +1035,7 @@ props[this.selectedAs] = true; props.tabIndex = true; this._instanceProps = props; - this._userTemplate = Polymer.dom(this).querySelector('template'); + this._userTemplate = this.queryEffectiveChildren('template'); if (this._userTemplate) { this.templatize(this._userTemplate); @@ -1619,7 +1626,8 @@ } var modelTabIndex, activeElTabIndex; var target = Polymer.dom(e).path[0]; - var activeEl = Polymer.dom(this.domHost ? this.domHost.root : document).activeElement; + var itemsHost = this._itemsParent.node.domHost; + var activeEl = Polymer.dom(itemsHost ? itemsHost.root : document).activeElement; var physicalItem = this._physicalItems[this._getPhysicalIndex(model[this.indexAs])]; // Safari does not focus certain form controls via mouse // https://bugs.webkit.org/show_bug.cgi?id=118043 @@ -1732,7 +1740,7 @@ _removeFocusedItem: function() { if (this._offscreenFocusedItem) { - Polymer.dom(this).removeChild(this._offscreenFocusedItem); + this._itemsParent.removeChild(this._offscreenFocusedItem); } this._offscreenFocusedItem = null; this._focusBackfillItem = null; @@ -1751,7 +1759,7 @@ // Create a physical item. var stampedTemplate = this.stamp(null); this._focusBackfillItem = stampedTemplate.root.querySelector('*'); - Polymer.dom(this).appendChild(stampedTemplate.root); + this._itemsParent.appendChild(stampedTemplate.root); } // Set the offcreen focused physical item. this._offscreenFocusedItem = this._physicalItems[pidx]; diff --git a/test/index.html b/test/index.html index 37820440..137aa3fa 100644 --- a/test/index.html +++ b/test/index.html @@ -28,7 +28,8 @@ 'different-heights.html', 'grid.html', 'grid-rtl.html', - 'bindings-host-to-item.html' + 'bindings-host-to-item.html', + 'template-overload.html' ]); diff --git a/test/o-list.html b/test/o-list.html new file mode 100644 index 00000000..74354540 --- /dev/null +++ b/test/o-list.html @@ -0,0 +1,30 @@ + + + + + + + + + + diff --git a/test/physical-count.html b/test/physical-count.html index 3df17bd3..79b35f69 100644 --- a/test/physical-count.html +++ b/test/physical-count.html @@ -90,7 +90,7 @@ test('pool should not increase if the list has no size', function(done) { container.style.display = 'none'; list.fire('iron-resize'); - + flush(function() { assert.equal(list._physicalCount, 0); done(); diff --git a/test/template-overload.html b/test/template-overload.html new file mode 100644 index 00000000..092bec83 --- /dev/null +++ b/test/template-overload.html @@ -0,0 +1,84 @@ + + + + + + iron-list test + + + + + + + + + + + + + + + + + + + + + + +