Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sort on dom-repeat template causes exception on splice #2297

Closed
MaKleSoft opened this issue Aug 18, 2015 · 3 comments
Closed

Sort on dom-repeat template causes exception on splice #2297

MaKleSoft opened this issue Aug 18, 2015 · 3 comments
Assignees

Comments

@MaKleSoft
Copy link

When I use a sort function on a dom-repeat template and call splice to remove more than 10 items from the list at once, the following exception is thrown and the splice is only partially applied:

Uncaught TypeError: Cannot read property 'isPlaceholder' of undefined
    Polymer._detachRow  @   polymer.html:3906
    Polymer._applySplicesUserSort   @   polymer.html:3833
    Polymer._render @   polymer.html:3741
    Debouncer.complete  @   polymer.html:1118
    Polymer.Async._atEndOfMicrotask @   polymer.html:1079

For some reason, removing 10 items or less is fine. Here is a minimal example for reproducing the problem:

<dom-module id="list-test">
    <template>

        <template is="dom-repeat" items="{{ items }}" sort="sort">

            <div>{{ item }}</div>

        </template>

        <button on-tap="removeItems">Remote first 11 items</button>

    </template>

    <script>

        Polymer({
            is: "list-test",
            properties: {
                items: {
                    type: Array,
                    value: [0,1,2,3,4,5,6,7,8,9,10,11]
                }
            },
            sort: function(a, b) {
                return a - b;
            },
            removeItems: function() {
                // This causes an exception
                // Removing less than 11 items is fine for some reason
                this.splice("items", 0, 11);
            }
        });

    </script>
</dom-module>
@MaKleSoft
Copy link
Author

Possibly related to #2292

@dfreedm
Copy link
Member

dfreedm commented Aug 19, 2015

@MaKleSoft
Copy link
Author

Can confirm the fix on my side. It's amazing how fast this issue was addressed and fixed. Thanks, guys!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants