Skip to content

Reducing the number of items in the array will not render correctly #106

@altenstedt

Description

@altenstedt

I'm submitting a bug report

  • Library Version:
    1.0.0-beta.3.0.2

Please tell us about your environment:

  • Operating System:
    Windows 10

  • Node Version:
    4.5.0

  • NPM Version:
    3.8.9

  • JSPM OR Webpack AND Version
    JSPM 0.16.32

  • Browser:
    all

  • Language:
    all

Current behavior:

When reducing the number of items in the array, virtual-repeat.for will not render items correctly.

Expected/desired behavior:

The code in ArrayVirtualRepeatStrategy._inPlaceProcessItems does not seem to properly handle the case when a new array is bound to the virtual-repeat attribute that has fewer items than the current view
displays.

So, for example, if I have a view like so:

<div repeat.for="item of items"></div>

And update the items array in the view model like so:

this.items = array;

Notice that I re-bind to a new array. I am not using a value converter. This cause VirtualRepeat.itemsChanged to run.

Where array has fewer items that the previous value of this.items, then the code that access the items array around line 46 (items[i + first]) might access items outside the bounds of the new array, if the user is scrolled down in the view.

I do not understand the code enough to provide a fix, but I am willing to put in an effort given a little guidance. This module is very useful for us.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions