Skip to content

Loading…

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

Closed
MaKleSoft opened this Issue · 3 comments

3 participants

@MaKleSoft

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

Possibly related to #2292

@sorvell sorvell added the p1 label
@azakus azakus was assigned by sorvell
@azakus azakus added in progress p1 and removed p1 labels
@MaKleSoft

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

@sorvell sorvell closed this in #2314
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.