iron-list doesn't restore template when element gets recycled
Description
I use iron-swipeable-container in an iron-list. Swiping an item removes the DOM node within the iron-list entry. Setting afterwards new data fails to restore the deleted DOM node.
This does work with dom-repeat (see live demo: https://jsbin.com/cakizohagu/edit?html,output).
Expected outcome
DOM node should be restored according to the template in the iron-list.
Actual outcome
Data isn't visible (since the entry in the list doesn't have any longer the DOM node to show the data).
Live Demo
https://jsbin.com/cakizohagu/edit?html,output
Steps:
- Open live demo
- Swipe away item "B" from the first block (iron-list)
=> Now item "C" isn't any longer visible in the
iron-list(but still visible in thedom-repeatlist) - Click on button "Reset items"
=> Item "B" is still not visible in
iron-list(but is correctly visible indom-repeatlist)
Steps to reproduce
See JSBin
Browsers Affected
- [X] Chrome
- [X] Firefox
- [X] Safari 9
This issue looks similar to https://github.com/PolymerElements/iron-list/issues/257
Yes, it's the same issue. In this case, iron-swipeable-container removes the element from the light DOM. https://github.com/PolymerElements/iron-swipeable-container/blob/master/iron-swipeable-container.html#L257
Because the DOM was removed dynamically, those nodes can't be recycled, but iron-list is not aware of those changes. I wonder if iron-swipeable-container could trigger an event when it's about to remove the DOM and do nothing if the event is defaultPrevented. That way we could fix this issue. cc @notwaldorf