canjs / can-construct-super

Call base functions when extending can-constructs
https://canjs.com/doc/can-construct-super.html
MIT License
4 stars 0 forks source link

_super cannot be applied to sealed objects. #5

Closed bmomberger-bitovi closed 7 years ago

bmomberger-bitovi commented 8 years ago

(Note: This is a general issue with can-construct but I am reporting it here because this is where I found it and it is likely to show up in this context frequently)

When using can-construct-super with default DefineMaps, this._super cannot be set on the object because it is not part of the original object definition, and DefineMaps are sealed by default (preventing new properties like _super from being assigned). This completely nullifies the ability of can-construct-super to operate unless users specifically define _super on classes extended from DefineMap or use unsealed objects.

Done as a JSBin: https://jsbin.com/gareduwata/1/edit?html,js,output

There needs to be a generalized way of letting DefineMaps know that certain properties need to be universally exempt from being sealed out so other libraries can do their respective jobs. Please discuss how best to do so if you have an opinion.

justinbmeyer commented 7 years ago

I think can.Construct should have the ability to define properties for any instance. Something like:

can.Construct.defineInstanceProperty("_super", { ... });

Then, things like can-define can do what they must with this.

jcarbou commented 7 years ago

Hi,

since the new version 3.0.1 the workaround 2 ("https://jsbin.com/gareduwata/1/edit?html,js,output") for sealed objects fails :

_super: { type: "function" },

The _super always call "init" method of the parent class. I force 3.0.0 for my project to slove this problem.

justinbmeyer commented 7 years ago

@jcarbou does the work-around work with 3.0.2 which was released last night?

jcarbou commented 7 years ago

Yes !!

Thank you

justinbmeyer commented 7 years ago
Object.getPrototypeOf(this)._super =
andrejewski commented 7 years ago

Fixed by #21