diff --git a/cosmoz-data-nav.js b/cosmoz-data-nav.js index a5f2452..23c1eae 100644 --- a/cosmoz-data-nav.js +++ b/cosmoz-data-nav.js @@ -350,7 +350,11 @@ class CosmozDataNav extends hauntedPolymer('haunted', useDataNav)(mixinBehaviors this.splice('_elements', 0, this._elements.length, this._createElement()) .forEach(element => { - this._removeInstance(element.__instance); + if (this.renderItem) { + element.removeChild(element.__instance); + } else { + this._removeInstance(element.__instance); + } element.removeChild(element.__incomplete); element.__instance = element.__incomplete = null; }); diff --git a/test/basic.test.js b/test/basic.test.js index 33df92e..ff65034 100644 --- a/test/basic.test.js +++ b/test/basic.test.js @@ -1,3 +1,4 @@ +/* eslint-disable max-lines */ import { assert, fixture, html, oneEvent, waitUntil } from '@open-wc/testing'; @@ -400,3 +401,31 @@ suite('renderQueue', () => { }); }); }); + +suite('renderItem', () => { + let nav, + itemsRendered = 0; + const renderItem = (item, index) => { + itemsRendered += 1; + return html` + + + `; + }; + + suiteSetup(async () => { + [, nav] = await Promise.all([ + fixture(visibilityFixture), + setupFixture(html` + + + `) + ]); + }); + + test('renders items', async () => { + nav.items = [{ id: '0' }, { id: '1' }, { id: '2' }]; + flushRenderQueue(nav); + assert.equal(itemsRendered, nav.items.map(nav.isIncompleteFn).filter(i => !i).length); + }); +});