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

Duplicate strings in array while using 'dom-repeat' throws error: 'Uncaught Error: unexpected key undefined' #3062

Closed
ajtejankar opened this issue Nov 20, 2015 · 9 comments

Comments

@ajtejankar
Copy link

Following is the element I made which throws an error mentioned in the title.

<link rel="import" href="../polymer/polymer.html" />

<dom-module id="data-list">
    <template>
        <template is="dom-repeat" items={{data}}>
            <div>{{item}}</div>
        </template>
    </template>
    <script>
        Polymer({
            is: 'data-list',

            properties: {
                data: {
                    type: Array,
                    value: function() {
                        return ['Random', 'Random'];
                    },
                    notify: true
                }
            },

            attached: function() {
                this.splice('data', 0, 1);
                this.splice('data', 0, 1);
            }
        });
    </script>
</dom-module>

This is caused by storing values of an array as keys in the object pmap.

@fredefox
Copy link

I have noticed this too. Only after seeing this issue did I realize that it happens when you use non-unique values in the array. Do you have a work-around?

@ajtejankar
Copy link
Author

@fredefox Using objects instead of primitive values should do the trick.

@fredefox
Copy link

Right you are! Thank you.

@ajtejankar
Copy link
Author

I would really love to contribute a PR for this bug if somebody guides me on how to go about it. It would be my first ever PR on GitHub :).

@MeTaNoV
Copy link

MeTaNoV commented Dec 7, 2015

Just go ahead by following this: https://github.com/Polymer/project/blob/master/Contributing.md

ajtejankar added a commit to atomelements/t-data-feeder that referenced this issue Dec 10, 2015
@StokeMasterJack
Copy link

I too am getting this error. I am using an array of object which may contain duplicates. It happens on this line:

this.splice('selected', indexToRemove, 1);

and it seems t happen when deleting a duplicate for the second time.

@Pupix
Copy link

Pupix commented May 11, 2016

/sub

@electrovir
Copy link

electrovir commented Jun 24, 2016

I have an issue related to this but I am not getting an error thrown. Instead, when I use dom-repeat to bind an array with non-unique strings to input boxes, editing the text inside any input besides the first (using normal user interaction) changes the value in the first input box.

Also, this will happens even if the initial values of the bound array are not identical, but become identical later by user input.

@TimvdLippe
Copy link
Contributor

This has been fixed in Polymer 2: http://jsbin.com/fuqarizedo/edit?html,console,output

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

10 participants