diff --git a/lib/jutil.js b/lib/jutil.js index bcab34e6..68b0637b 100644 --- a/lib/jutil.js +++ b/lib/jutil.js @@ -66,18 +66,21 @@ exports.mixin = function (newClass, mixinClass, options) { }; function mixInto(sourceScope, targetScope, options) { - var proxies = []; - Object.keys(sourceScope).forEach(function (propertyName, options) { var targetPropertyExists = targetScope.hasOwnProperty(propertyName); var sourceProperty = Object.getOwnPropertyDescriptor(sourceScope, propertyName); var targetProperty = targetPropertyExists && Object.getOwnPropertyDescriptor(targetScope, propertyName); var sourceIsFunc = typeof sourceProperty.value === 'function'; - var shouldOverride = options.override || !targetPropertyExists || sourceIsFunc; + var isFunc = targetPropertyExists && typeof targetProperty.value === 'function'; + var isDelegate = isFunc && targetProperty.value._delegate; + var shouldOverride = options.override || !targetPropertyExists || isDelegate; if (shouldOverride) { + if (sourceIsFunc) { + sourceProperty.value = sourceProperty.value; + } + Object.defineProperty(targetScope, propertyName, sourceProperty); } }); } -