Permalink
Browse files

#1 addressed, cause was missing a .bind method translation

  • Loading branch information...
Jakobo committed Nov 16, 2011
1 parent 83f26ef commit 92cdf2808aaeb0c1529f29f9ac4ce540d7faa396
Showing with 13 additions and 6 deletions.
  1. +5 −3 README
  2. +6 −1 class-min.js
  3. +2 −2 class.js
View
8 README
@@ -2,8 +2,10 @@ It's Class.create() from prototype, but standalone. Yep, that's it.
Version 1.7 from https://github.com/sstephenson/prototype
-Unminified: 10k
-Minified: 3.3k
-Minified+gzip: 1.7k
+View the docs at http://www.prototypejs.org/learn/class-inheritance (the new way)
+
+Unminified: 9.11k
+Minified: 2.06k
+Minified+gzip: <1.7k
What's not to love?
View
@@ -22,4 +22,9 @@ SOFTWARE.
*
* Refer to Prototype's web site for a [tutorial on classes and
* inheritance](http://prototypejs.org/learn/class-inheritance).
-**/(function(a){function j(a){return b.call(a)===i}function k(a,b){for(var c in b)b.hasOwnProperty(c)&&(a[c]=b[c]);return a}function l(a){if(m(a)!==h)throw new TypeError;var b=[];for(var c in a)a.hasOwnProperty(c)&&b.push(c);return b}function m(a){switch(a){case null:return c;case void 0:return d}var b=typeof a;switch(b){case"boolean":return e;case"number":return f;case"string":return g}return h}function n(a){return typeof a=="undefined"}function p(a){var b=a.toString().match(/^[\s\(]*function[^(]*\(([^)]*)\)/)[1].replace(/\/\/.*?[\r\n]|\/\*(?:.|[\r\n])*?\*\//g,"").replace(/\s+/g,"").split(",");return b.length==1&&!b[0]?[]:b}function q(a,b){var c=a;return function(){var a=r([t(c,this)],arguments);return b.apply(this,a)}}function r(a,b){var c=a.length,d=b.length;while(d--)a[c+d]=b[d];return a}function s(a,b){return a=o.call(a,0),r(a,b)}function t(a,b){if(arguments.length<2&&n(arguments[0]))return this;var c=a,d=o.call(arguments,2);return function(){var a=s(d,arguments);return c.apply(b,a)}}var b=Object.prototype.toString,c="Null",d="Undefined",e="Boolean",f="Number",g="String",h="Object",i="[object Function]",o=Array.prototype.slice,u=function(){},v=function(){function b(){}function c(){function d(){this.initialize.apply(this,arguments)}var a=null,c=[].slice.apply(arguments);j(c[0])&&(a=c.shift()),k(d,v.Methods),d.superclass=a,d.subclasses=[],a&&(b.prototype=a.prototype,d.prototype=new b,a.subclasses.push(d));for(var e=0,f=c.length;e<f;e++)d.addMethods(c[e]);return d.prototype.initialize||(d.prototype.initialize=u),d.prototype.constructor=d,d}function d(b){var c=this.superclass&&this.superclass.prototype,d=l(b);a&&(b.toString!=Object.prototype.toString&&d.push("toString"),b.valueOf!=Object.prototype.valueOf&&d.push("valueOf"));for(var e=0,f=d.length;e<f;e++){var g=d[e],h=b[g];if(c&&j(h)&&p(h)[0]=="$super"){var i=h;h=q(function(a){return function(){return c[a].apply(this,arguments)}}(g),i),h.valueOf=i.valueOf.bind(i),h.toString=i.toString.bind(i)}this.prototype[g]=h}return this}var a=function(){for(var a in{toString:1})if(a==="toString")return!1;return!0}();return{create:c,Methods:{addMethods:d}}}();a.exports?a.exports.Class=v:a.Class=v})(this)
+**/
+(function(h){function p(a,c){for(var b in c)c.hasOwnProperty(b)&&(a[b]=c[b]);return a}function q(a){if(r(a)!==l)throw new TypeError;var c=[],b;for(b in a)a.hasOwnProperty(b)&&c.push(b);return c}function r(a){switch(a){case null:return s;case void 0:return t}switch(typeof a){case "boolean":return u;case "number":return v;case "string":return w}return l}function x(a){a=a.toString().match(/^[\s\(]*function[^(]*\(([^)]*)\)/)[1].replace(/\/\/.*?[\r\n]|\/\*(?:.|[\r\n])*?\*\//g,"").replace(/\s+/g,"").split(",");
+return a.length==1&&!a[0]?[]:a}function y(a,c){return function(){var b=m([k(a,this)],arguments);return c.apply(this,b)}}function m(a,c){for(var b=a.length,d=c.length;d--;)a[b+d]=c[d];return a}function k(a,c){if(arguments.length<2&&typeof arguments[0]==="undefined")return this;var b=a,d=n.call(arguments,2);return function(){var a;a=d;var e=arguments;a=n.call(a,0);a=m(a,e);return b.apply(c,a)}}var o=Object.prototype.toString,s="Null",t="Undefined",u="Boolean",v="Number",w="String",l="Object",n=Array.prototype.slice,
+z=function(){},f=function(){function a(){}var c=function(){for(var a in{toString:1})if(a==="toString")return false;return true}();return{create:function(){function b(){this.initialize.apply(this,arguments)}var d=null,c=[].slice.apply(arguments);o.call(c[0])==="[object Function]"&&(d=c.shift());p(b,f.Methods);b.superclass=d;b.subclasses=[];if(d)a.prototype=d.prototype,b.prototype=new a,d.subclasses.push(b);for(var d=0,e=c.length;d<e;d++)b.addMethods(c[d]);if(!b.prototype.initialize)b.prototype.initialize=
+z;return b.prototype.constructor=b},Methods:{addMethods:function(a){var d=this.superclass&&this.superclass.prototype,j=q(a);c&&(a.toString!=Object.prototype.toString&&j.push("toString"),a.valueOf!=Object.prototype.valueOf&&j.push("valueOf"));for(var e=0,h=j.length;e<h;e++){var f=j[e],g=a[f];if(d&&o.call(g)==="[object Function]"&&x(g)[0]=="$super"){var i=g,g=y(function(a){return function(){return d[a].apply(this,arguments)}}(f),i);g.valueOf=k(i.valueOf,i);g.toString=k(i.toString,i)}this.prototype[f]=
+g}return this}}}}();h.exports?h.exports.Class=f:h.Class=f})(this);
View
@@ -271,8 +271,8 @@ var Class = (function() {
return function() { return ancestor[m].apply(this, arguments); };
})(property), method);
- value.valueOf = method.valueOf.bind(method);
- value.toString = method.toString.bind(method);
+ value.valueOf = bind(method.valueOf, method);
+ value.toString = bind(method.toString, method);
}
this.prototype[property] = value;
}

0 comments on commit 92cdf28

Please sign in to comment.