WICG / virtual-scroller

Other
2k stars 83 forks source link

header-footer demo bug with recycle item #150

Closed panther7 closed 5 years ago

panther7 commented 5 years ago

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();
        }
     };
valdrinkoshi commented 5 years ago

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

rakina commented 5 years ago

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: https://github.com/valdrinkoshi/virtual-scroller/issues/158#issuecomment-480913127.

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!