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

extending a can Control with defaults properties is changing the super Class defaults #65

Closed
justinbmeyer opened this issue Sep 7, 2018 · 0 comments · Fixed by #73
Closed
Labels

Comments

@justinbmeyer
Copy link
Contributor

@Mamuuut commented on Thu Sep 06 2018

If an Object is part of a Class defaults and this Class is extended with defaults having a different Object with the same property name. The super Class defaults Object properties will be overwritten.

Here is an example with CanJS v4:
https://codepen.io/Mamuuut/pen/oPGLgE

It was not the case in v3:
https://codepen.io/Mamuuut/pen/OoxXPq?editors=1111

And it still is in v5:
https://codepen.io/Mamuuut/pen/bKyryV

This seems related to the can Construct setup method:

	setup: function (base) {
		var defaults = canReflect.assignDeepMap({},base.defaults);
		this.defaults = canReflect.assignDeepMap(defaults,this.defaults);
	},

assignDeepMap does not create a deep copy of the base.defaults and then those are overwritten by this.defaults…


@justinbmeyer commented on Thu Sep 06 2018

Can you try:

var defaults = canReflect.serialize(base.defaults);
this.defaults = canReflect.assignDeepMap(defaults,this.defaults);

Let me know if this works. Thanks!


@Mamuuut commented on Fri Sep 07 2018

It works:

https://codepen.io/Mamuuut/pen/MqEMaa

Thanks!

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

Successfully merging a pull request may close this issue.

2 participants