Skip to content

Commit

Permalink
Fixed #4342 - Rename merge and useMergeProps options with mergeSectio…
Browse files Browse the repository at this point in the history
…ns and mergeProps options on usePassThrough method
  • Loading branch information
mertsincan committed Aug 28, 2023
1 parent ed62934 commit c57faf3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions components/lib/basecomponent/BaseComponent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -508,15 +508,15 @@ export default {
const fn = (value) => callback(value, key, params);
if (pt?.hasOwnProperty('_usept')) {
const { merge, useMergeProps } = pt['_usept'];
const { mergeSections, mergeProps: useMergeProps } = pt['_usept'];
const originalValue = fn(pt.originalValue);
const value = fn(pt.value);
if (originalValue === undefined && value === undefined) return undefined;
else if (ObjectUtils.isString(value)) return value;
else if (ObjectUtils.isString(originalValue)) return originalValue;
return merge ? (useMergeProps ? mergeProps(originalValue, value) : { ...originalValue, ...value }) : value;
return mergeSections || (!mergeSections && value) ? (useMergeProps ? mergeProps(originalValue, value) : { ...originalValue, ...value }) : value;
}
return fn(pt);
Expand Down
4 changes: 2 additions & 2 deletions components/lib/basedirective/BaseDirective.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,15 @@ const BaseDirective = {
const fn = (value) => callback(value, key, params);

if (pt?.hasOwnProperty('_usept')) {
const { merge, useMergeProps } = pt['_usept'];
const { mergeSections, mergeProps: useMergeProps } = pt['_usept'];
const originalValue = fn(pt.originalValue);
const value = fn(pt.value);

if (originalValue === undefined && value === undefined) return undefined;
else if (ObjectUtils.isString(value)) return value;
else if (ObjectUtils.isString(originalValue)) return originalValue;

return merge ? (useMergeProps ? mergeProps(originalValue, value) : { ...originalValue, ...value }) : value;
return mergeSections || (!mergeSections && value) ? (useMergeProps ? mergeProps(originalValue, value) : { ...originalValue, ...value }) : value;
}

return fn(pt);
Expand Down
12 changes: 6 additions & 6 deletions components/lib/passthrough/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
* @todo: Add dynamic params support;
*
* Exp;
* usePassThrough(pt1, pt2, pt3, pt*, { merge: true });
* usePassThrough(pt1, { merge: true });
* usePassThrough(pt1, pt2, pt3, pt*, { mergeSections: true });
* usePassThrough(pt1, { mergeSections: true });
*/
export const usePassThrough = (pt1 = {}, pt2 = {}, { merge = true, useMergeProps = true } = {}) => {
export const usePassThrough = (pt1 = {}, pt2 = {}, { mergeSections = true, mergeProps = false } = {}) => {
return {
_usept: {
merge,
useMergeProps
mergeSections,
mergeProps
},
originalValue: pt1,
value: pt2
value: { ...pt1, ...pt2 }
};
};

0 comments on commit c57faf3

Please sign in to comment.