diff --git a/lib/MemberBuilder.js b/lib/MemberBuilder.js index a55e0cb..3eafb77 100644 --- a/lib/MemberBuilder.js +++ b/lib/MemberBuilder.js @@ -142,7 +142,7 @@ exports.buildMethod = function( { // we are not overriding the method, so simply copy it over, wrapping it // to ensure privileged calls will work properly - dest[ name ] = this._overrideMethod( value, null, instCallback, cid ); + dest[ name ] = this._overrideMethod( null, value, instCallback, cid ); } // store keywords for later reference (needed for pre-ES5 fallback) @@ -579,11 +579,11 @@ exports._overrideMethod = function( // __super property var override = null; - // should we override or wrap as a new method? + // are we overriding? override = ( - ( new_method ) - ? this._wrapMethod - : this._wrapOverride + ( super_method ) + ? this._wrapOverride + : this._wrapMethod ).wrapMethod( new_method, super_method, cid, instCallback ); // This is a trick to work around the fact that we cannot set the length @@ -593,7 +593,7 @@ exports._overrideMethod = function( // compatibility with its super method. util.defineSecureProp( override, '__length', - ( super_method.__length || super_method.length ) + ( new_method.__length || new_method.length ) ); return override; diff --git a/lib/MethodWrappers.js b/lib/MethodWrappers.js index ae058da..6b71256 100644 --- a/lib/MethodWrappers.js +++ b/lib/MethodWrappers.js @@ -27,7 +27,7 @@ * @type {Object} */ exports.standard = { - wrapNew: function( method, super_method, cid, getInst ) + wrapOverride: function( method, super_method, cid, getInst ) { return function() { @@ -60,7 +60,7 @@ exports.standard = { }, - wrapOverride: function( method, super_method, cid, getInst ) + wrapNew: function( method, super_method, cid, getInst ) { return function() { @@ -69,7 +69,7 @@ exports.standard = { ; // invoke the method - retval = super_method.apply( context, arguments ); + retval = method.apply( context, arguments ); // if the value returned from the method was the context that we // passed in, return the actual instance (to ensure we do not break