You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Calling a CanMap constructor inside of a getter sets up a binding on __keys for the created instance, which means that setting any property on that instance will cause the getter to rerun.
import { CanMap } from "//unpkg.com/can@5/ecosystem.mjs";
const OtherMap = CanMap.extend({});
const MyMap = CanMap.extend({
define: {
foo: {
get() {
// calling this constructor sets up a binding on __keys
return new OtherMap();
}
}
}
});
var map = new MyMap();
map.on('foo', () => {});
map.attr('foo.bar', 'baz'); // triggers a `__keys` event on the `OtherMap`, which causes the `foo` getter to rerun
console.log( map.attr('foo.bar') ); // -> undefined because `foo` is a new `OtherMap` instance
This happens because the constructor calls canReflect.assignDeep, which ends up calling getOwnEnumerableKeys, which creates this binding:
Calling a CanMap constructor inside of a getter sets up a binding on
__keys
for the created instance, which means that setting any property on that instance will cause the getter to rerun.This happens because the constructor calls
canReflect.assignDeep
, which ends up callinggetOwnEnumerableKeys
, which creates this binding:can-map/can-map.js
Line 659 in c1dca96
I think this is a regression from 2.3, where this did not happen.
The text was updated successfully, but these errors were encountered: