-
Notifications
You must be signed in to change notification settings - Fork 247
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: dedupe meta objects by VMID #282
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
import deepmerge from 'deepmerge' | ||
import uniqBy from 'lodash.uniqby' | ||
import uniqueId from 'lodash.uniqueid' | ||
|
||
/** | ||
* Returns the `opts.option` $option value of the given `opts.component`. | ||
|
@@ -15,7 +17,7 @@ import deepmerge from 'deepmerge' | |
* @return {Object} result - final aggregated result | ||
*/ | ||
export default function getComponentOption (opts, result = {}) { | ||
const { component, option, deep, arrayMerge, metaTemplateKeyName, contentKeyName } = opts | ||
const { component, option, deep, arrayMerge, metaTemplateKeyName, tagIDKeyName, contentKeyName } = opts | ||
const { $options } = component | ||
|
||
if (component._inactive) return result | ||
|
@@ -64,6 +66,10 @@ export default function getComponentOption (opts, result = {}) { | |
|
||
return metaObject | ||
}) | ||
result.meta = uniqBy( | ||
result.meta.reverse(), | ||
metaObject => metaObject.hasOwnProperty(tagIDKeyName) ? metaObject[tagIDKeyName] : uniqueId() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I had to implement a workaround for tags without My first idea was to use So I had to use another lodash fn |
||
) | ||
} | ||
return result | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had to reverse the list to always consider the last meta object as the "true" one