Fixed #4707 - PassThought new merging strategy

pull/5134/head^2
mertsincan 2024-01-29 12:35:09 +00:00
parent ecdceba4d1
commit c749f0522b
3 changed files with 13 additions and 5 deletions

View File

@ -82,6 +82,9 @@ export default {
defaultHook?.();
}
},
_mergeProps(fn, ...args) {
return ObjectUtils.isFunction(fn) ? fn(...args) : mergeProps(...args);
},
_loadGlobalStyles() {
/*
* @todo Add self custom css support;
@ -124,7 +127,7 @@ export default {
[`${datasetPrefix}section`]: ObjectUtils.toFlatCase(key)
};
return mergeSections || (!mergeSections && self) ? (useMergeProps ? mergeProps(global, self, datasets) : { ...global, ...self, ...datasets }) : { ...self, ...datasets };
return mergeSections || (!mergeSections && self) ? (useMergeProps ? this._mergeProps(useMergeProps, global, self, datasets) : { ...global, ...self, ...datasets }) : { ...self, ...datasets };
},
_getPTClassValue(...args) {
const value = this._getOptionValue(...args);
@ -160,7 +163,7 @@ export default {
else if (ObjectUtils.isString(value)) return value;
else if (ObjectUtils.isString(originalValue)) return originalValue;
return mergeSections || (!mergeSections && value) ? (useMergeProps ? mergeProps(originalValue, value) : { ...originalValue, ...value }) : value;
return mergeSections || (!mergeSections && value) ? (useMergeProps ? this._mergeProps(useMergeProps, originalValue, value) : { ...originalValue, ...value }) : value;
}
return fn(pt);

View File

@ -31,7 +31,7 @@ const BaseDirective = {
[`${datasetPrefix}section`]: ObjectUtils.toFlatCase(key)
};
return mergeSections || (!mergeSections && self) ? (useMergeProps ? mergeProps(global, self, datasets) : { ...global, ...self, ...datasets }) : { ...self, ...datasets };
return mergeSections || (!mergeSections && self) ? (useMergeProps ? BaseDirective._mergeProps(instance, useMergeProps, global, self, datasets) : { ...global, ...self, ...datasets }) : { ...self, ...datasets };
},
_getPT: (pt, key = '', callback) => {
const getValue = (value) => {
@ -61,7 +61,7 @@ const BaseDirective = {
else if (ObjectUtils.isString(value)) return value;
else if (ObjectUtils.isString(originalValue)) return originalValue;
return mergeSections || (!mergeSections && value) ? (useMergeProps ? mergeProps(originalValue, value) : { ...originalValue, ...value }) : value;
return mergeSections || (!mergeSections && value) ? (useMergeProps ? BaseDirective._mergeProps(instance, useMergeProps, originalValue, value) : { ...originalValue, ...value }) : value;
}
return fn(pt);
@ -80,6 +80,9 @@ const BaseDirective = {
selfHook?.(instance, options);
defaultHook?.(instance, options);
},
_mergeProps(instance = {}, fn, ...args) {
return ObjectUtils.isFunction(fn) ? fn(...args) : mergeProps(...args);
},
_extend: (name, options = {}) => {
const handleHook = (hook, el, binding, vnode, prevVnode) => {
el._$instances = el._$instances || {};

View File

@ -1,6 +1,8 @@
export declare type PassThroughMergePropsType = ((...args: any) => object | undefined) | boolean | undefined;
export interface PassThroughOptions {
mergeSections?: boolean | undefined;
mergeProps?: boolean | undefined;
mergeProps?: PassThroughMergePropsType;
}
export declare function usePassThrough(pt1: object, pt2: object, options?: PassThroughOptions): object;