!fixup Require ._delegate for fn override

This commit is contained in:
Ritchie Martori 2014-05-20 13:44:25 -07:00
parent 072999775e
commit e724efd95f
1 changed files with 7 additions and 4 deletions

View File

@ -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);
}
});
}