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

canRoute.data is not observable when using can-simple-map #119

Open
phillipskevin opened this issue Oct 16, 2017 · 0 comments
Open

canRoute.data is not observable when using can-simple-map #119

phillipskevin opened this issue Oct 16, 2017 · 0 comments
Assignees
Labels

Comments

@phillipskevin
Copy link
Contributor

phillipskevin commented Oct 16, 2017

Using canRoute.data like this:

const view = stache('{{page}}');

canRoute('{page}', {page: 'home'});
canRoute.ready();

document.body.appendChild(
    view( canRoute.data )
);

does not work if types.DefaultMap is not set (and therefore uses can-simple-map). This error is thrown:

steal.js:7324 Error: can-reflect: can not observe value change
    at Object.canReflect.onValue (observe.js:25)
    at Observation.addEdge (can-observation.js:197)
    at Observation.updateBindings (can-observation.js:282)
    at Observation.start (can-observation.js:269)
    at Compute._on (proto-compute.js:151)
    at Compute.eval (proto-compute.js:331)
    at Compute.eval [as _eventSetup] (can-observation.js:591)
    at Compute.prototype.addEventListener (lifecycle.js:30)
    at Function.addEventListener (can-compute.js:49)
    at Function._setup (can-route.js:832)

Setting canRoute.data explicitly fixes the issue:

canRoute.data = new SimpleMap();

This code is causing the issue:

can-route/can-route.js

Lines 258 to 279 in 72a5061

var stringCoercingMapDecorator = function(map) {
var sym = canSymbol.for("can.route.stringCoercingMapDecorator");
if(!map.attr[sym]) {
var attrSuper = map.attr;
map.attr = function(prop, val) {
var serializable = this.define === undefined || this.define[prop] === undefined || !!this.define[prop].serialize,
args;
if (serializable) { // if setting non-str non-num attr
args = stringify(Array.apply(null, arguments));
} else {
args = arguments;
}
return attrSuper.apply(this, args);
};
canReflect.setKeyValue(map.attr, sym, true);
}
return map;
};

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

No branches or pull requests

2 participants