tnhu / jsface

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

instanceof does not work for jsface #20

Closed seanzhou321 closed 9 years ago

seanzhou321 commented 10 years ago

Hi, jsface is very nice given its speed and simplicity. I only found one issue that instanceof is broken for classes created by jsface. Besides of fixing instanceof, I have one wish to have instanceof also works for mixins, which acts as interfaces. Thanks.

tnhu commented 10 years ago

Thank you for reporting. It'd be helpful if you could paste some samples?

seanzhou321 commented 10 years ago

var jf = require('jsface');

var Parent = jf.Class({ name: 'Parent' });

var Parent2mix = jf.Class({ mixMe: function() {console.log('mixme.');} });

var Child = jf.Class([Parent, Parent2mix], { childAction: function() { console.log('child Action.');} });

var aChild = new Child();

console.log('instanceof Parent?', aChild instanceof Parent); console.log('instanceof Parent2mix?', aChild instanceof Parent2mix);


The results returned are all false, which both should be true.