diff --git a/classy.js b/classy.js index 9ca6051..10402c9 100644 --- a/classy.js +++ b/classy.js @@ -4,14 +4,15 @@ * :copyright: (c) 2011 by Armin Ronacher. * :license: BSD. */ +!function (context) { +'use strict'; !function (definition) { if (typeof module != 'undefined' && module.exports) module.exports = definition() else if (typeof define == 'function' && typeof define.amd == 'object') define(definition) - else this.Class = definition() -}(function (undefined) { + else context.Class = definition() +}(function (undefined) { var CLASSY_VERSION = '1.4', - context = this, old = context.Class, disable_constructor = false; @@ -122,7 +123,7 @@ var rv = function() { if (disable_constructor) return; - var proper_this = context === this ? cheapNew(arguments.callee) : this; + var proper_this = this instanceof rv ? this : cheapNew(rv); if (proper_this.__init__) proper_this.__init__.apply(proper_this, arguments); proper_this.$class = rv; @@ -158,4 +159,5 @@ /* export the class */ return Class; -}); \ No newline at end of file +}); +}(this);