Skip to content

Commit

Permalink
Fixed #4707 - PassThought new merging strategy
Browse files Browse the repository at this point in the history
  • Loading branch information
mertsincan committed Jan 29, 2024
1 parent ecdceba commit c749f05
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
7 changes: 5 additions & 2 deletions components/lib/basecomponent/BaseComponent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
7 changes: 5 additions & 2 deletions components/lib/basedirective/BaseDirective.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down Expand Up @@ -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);
Expand All @@ -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 || {};
Expand Down
4 changes: 3 additions & 1 deletion components/lib/passthrough/index.d.ts
Original file line number Diff line number Diff line change
@@ -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;

0 comments on commit c749f05

Please sign in to comment.