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

Cannot create a List from a frozen Array #82

Open
ivospinheiro opened this issue Jul 27, 2018 · 1 comment
Open

Cannot create a List from a frozen Array #82

ivospinheiro opened this issue Jul 27, 2018 · 1 comment

Comments

@ivospinheiro
Copy link

ivospinheiro commented Jul 27, 2018

Cannot create a CanList from a frozen array of values using the version [email protected].

I'm having this error:
TypeError: Cannot add property _cid, object is not extensible

Here is a snippet of the code:

const canList = require("can-list");

const arr = [1,2,3];
Object.freeze(arr);

const list = new canList(arr);
console.log(list.serialize());

Here is an example of the error using [email protected]:
https://codesandbox.io/embed/p7vz6r2490?expanddevtools=1

And one working using the latest [email protected]:
https://codesandbox.io/embed/wyz0qq3wl5?expanddevtools=1

@ivospinheiro ivospinheiro changed the title Cannot create a CanList from an Array of values Cannot create a List from an Array of values Jul 27, 2018
@ivospinheiro ivospinheiro changed the title Cannot create a List from an Array of values Cannot create a List from a frozen Array Jul 27, 2018
@justinbmeyer
Copy link
Contributor

justinbmeyer commented Jul 27, 2018

So we add cid to avoid infinite loops due to cycles. For example, creating a list with an Array that contains an object that contains the original Array.

This error probably started happening b/c we added "use strict".

We should probably make CID provide a random number for sealed objects.

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

No branches or pull requests

2 participants