Small, fast, elegant, powerful, and cross platform JavaScript OOP library. Support main(), singleton, super call, private, mixins, plugins, AOP and more.
MIT License
301
stars
46
forks
source link
getters & inheritance don't work (gets evaluated while inheriting) #37
// define a class with a getter
var test1 = Class({
constructor: function(socket)
{
this._should_exist = {yep: true};
},
// this getter will mess things up...
should_exist: {
get: function() {
return this._should_exist.yep;
}
},
});
// then inherit from it.
// this part will evaluate the 'should_exist' getter and will cause exception, since _should_exist is not yet defined.
var test2 = Class(test1, {
});
The code above will invoke exception: TypeError: Cannot read property 'yep' of undefined. The reason for that, I assume, is because probably somewhere inside jsface tries to copy the prototype attribute should_exist, but instead of copying the definition it tries to evaluate it to return the value.
Consider the following code:
The code above will invoke exception: TypeError: Cannot read property 'yep' of undefined. The reason for that, I assume, is because probably somewhere inside jsface tries to copy the prototype attribute should_exist, but instead of copying the definition it tries to evaluate it to return the value.
I didn't look too deep into it though.