!fixup Require ._delegate for fn override
This commit is contained in:
parent
072999775e
commit
e724efd95f
11
lib/jutil.js
11
lib/jutil.js
|
@ -66,18 +66,21 @@ exports.mixin = function (newClass, mixinClass, options) {
|
||||||
};
|
};
|
||||||
|
|
||||||
function mixInto(sourceScope, targetScope, options) {
|
function mixInto(sourceScope, targetScope, options) {
|
||||||
var proxies = [];
|
|
||||||
|
|
||||||
Object.keys(sourceScope).forEach(function (propertyName, options) {
|
Object.keys(sourceScope).forEach(function (propertyName, options) {
|
||||||
var targetPropertyExists = targetScope.hasOwnProperty(propertyName);
|
var targetPropertyExists = targetScope.hasOwnProperty(propertyName);
|
||||||
var sourceProperty = Object.getOwnPropertyDescriptor(sourceScope, propertyName);
|
var sourceProperty = Object.getOwnPropertyDescriptor(sourceScope, propertyName);
|
||||||
var targetProperty = targetPropertyExists && Object.getOwnPropertyDescriptor(targetScope, propertyName);
|
var targetProperty = targetPropertyExists && Object.getOwnPropertyDescriptor(targetScope, propertyName);
|
||||||
var sourceIsFunc = typeof sourceProperty.value === 'function';
|
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 (shouldOverride) {
|
||||||
|
if (sourceIsFunc) {
|
||||||
|
sourceProperty.value = sourceProperty.value;
|
||||||
|
}
|
||||||
|
|
||||||
Object.defineProperty(targetScope, propertyName, sourceProperty);
|
Object.defineProperty(targetScope, propertyName, sourceProperty);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue