WICG / virtual-scroller

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

header-footer demo bug with recycle item

panther7 opened this issue · comments

This code cause duplicating older items:

https://github.com/valdrinkoshi/virtual-scroller/blob/ce533a6c5ec8754e399bc94a2a6ca000e7ae7151/demo/header-footer.html#L63-L69

Following code fixing them:

     virtualScroller.recycleElement = (element, item) => { 
        switch (element.tagName) {
          case "HEADER":
            nodePool.group.push(element);
            break;
          case "CONTACT-ELEMENT":
            nodePool.contact.push(element);
            break;
          default: element.remove();
        }
     };

Confirmed, recycleElement receives unexpected data when invoked after user modifies the items array, here a smaller reproduction: https://jsbin.com/yogiwesoqu/1/edit?html,console,output
Note how the item.group will not match with the element type received as input after we alter the array

Closing this as this is related to the virtual-scroller prototype implementation and we intend to make this repository focus on the standards side of it. See also: #158 (comment).

FYI we're going to have a separate demos repository later on, that can be used with Chromium's implementation of the new approach. Stay tuned for updates!