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

can.route.attr({}, true) throws an error #98

Open
phillipskevin opened this issue Jul 12, 2017 · 3 comments
Open

can.route.attr({}, true) throws an error #98

phillipskevin opened this issue Jul 12, 2017 · 3 comments

Comments

@phillipskevin
Copy link
Contributor

Passing an object as the first argument to can.route.attr and anything as the second argument throws an error:

can.route.attr({
  page: 'foo'
}, true);
error TypeError: Cannot define property _instanceDefinitions, object is not extensible
    at Function.defineProperty (<anonymous>)
    at Object.defineExpando (https://unpkg.com/[email protected]/dist/global/can.all.js:14845:24)
    at DefineMap.setKeyValue (https://unpkg.com/[email protected]/dist/global/can.all.js:14939:37)
    at Object.setKeyValue (https://unpkg.com/[email protected]/dist/global/can.all.js:1042:36)
    at DefineMap.attrHelper (https://unpkg.com/[email protected]/dist/global/can.all.js:15725:28)
    at Function.canRoute.attr (https://unpkg.com/[email protected]/dist/global/can.all.js:16107:27)

Here is an example: http://jsbin.com/dipiwikida/1/edit?js,console.

I think this is happening because people were previously using can-map and wanted to set the removeOthers flag and have now switched their appViewModel to DefineMap.

@phillipskevin
Copy link
Contributor Author

A workaround is to use can.route.data.set(..., true) if you are using a DefineMap to back can-route.

@green3g
Copy link

green3g commented Jul 24, 2017

I was running into this when I was binding to a route that was using a defineMap.extend. I fixed it by using {seal:false} on the extended define map.

@phillipskevin
Copy link
Contributor Author

Related to canjs/can-define#245.

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