3 ms·
Huh, weird. This seems to crib very heavily from my original Simple JavaScript Inheritance implementation: http://ejohn.org/blog/simple-javascript-inheritance/
by jeresig 17y ago
Huh, weird. This seems to crib very heavily from my original Simple JavaScript Inheritance implementation:
http://ejohn.org/blog/simple-javascript-inheritance/ http://ejohn.org/blog/simple-javascript-inheritance/
It even uses the 'classy' name and logo (stemming from an April Fools joke that I ran that used the aforementioned inheritance implementation):
http://ejohn.org/blog/classy-query/ http://ejohn.org/blog/classy-query/
Seems like he may have made some improvements to the code (using hasOwnProperty and putting a try/finally around the code block are two changes that I see) but on the whole it looks very very similar to the original implementation that I wrote. Odd.
Update: It seems as if the author credits the original code in a tweet that he made:
http://twitter.com/mitsuhiko/status/12902227050 http://twitter.com/mitsuhiko/status/12902227050
- hammerdr 17y agoThe reversal of the "extends" paradigm is interesting. It seems very natural. What made you go with that? (I know I'm not really responding to your comment but I think it speaks for itself).
- jeresig 17y agoGood question - I was inspired heavily by Dean Edwards' original Base Class library, it seemed to make the most sense when I was using it. The original code: http://dean.edwards.name/weblog/2006/03/base/ http://dean.edwards.name/weblog/2006/03/base/ The current code: http://code.google.com/p/base2/source/browse/trunk/src/base2/Base.js http://code.google.com/p/base2/source/browse/trunk/src/base2...
- the_mitsuhiko 17y ago> The reversal of the "extends" paradigm is interesting. It seems very natural. What made you go with that? I think the earliest version of that was prototype which I think used Class.create and Object.extend. I've seen that in many JavaScript class implementations so far.
- the_mitsuhiko 17y ago> Huh, weird. This seems to crib very heavily from my original Simple JavaScript Inheritance implementation: http://ejohn.org/blog/simple-javascript-inheritance/ http://ejohn.org/blog/simple-javascript-inheritance/ It is, see the AUTHORS file which credits that URL. In fact I was using a slightly modified version of your code for a long time but had to do some changes in order to use it for a project of mine. Basically I need classes implemented in a way that they will work in the presence of any other JavaScript framework. Reason: this JavaScript is injected into unknown code by a middleware system. > It even uses the 'classy' name and logo (stemming from an April Fools joke that I ran that used the aforementioned inheritance implementation): http://ejohn.org/blog/classy-query/ http://ejohn.org/blog/classy-query/ Interesting. I did not know that one. Name was rather obvious and did not return any direct hits with projects named like this so I went with it. The original drawing of that logo is the search result on Google images for "classy" with filter set to linedrawing. Original author unknown, I just vectorized it. > ... but on the whole it looks very very similar to the original implementation that I wrote. Odd. If you want a more obvious attribution than the AUTHORS file, just let me know. Other changes besides hasOwnProperty, the ability to use the library without modifying window, and $ prefixed names so that it does not clash with custom attributes is a more python/javascript inspired naming scheme for special methods and attributes (__init__ etc.) and support for mixins. Also attributes are properly removed if they were unset previously and not just reassigned with undefined and classes can be instanciated without new like in Python. Can't count how often my code did funny stuff because I forgot new there :) All in all, the idea is to have that fairly common piece of object orientated JavaScript class bootstrapping under an open source license so that anyone can use it. I hope I succeeded with that.