2
0
mirror of https://github.com/tenrok/vue-meta.git synced 2026-06-09 04:32:25 +03:00

feat: dedupe local meta object by VMID

This commit is contained in:
Alexander Lichter
2018-12-18 11:14:07 +00:00
parent 3eac2b9fe2
commit c590d8a4a7
4 changed files with 20 additions and 1 deletions
+10
View File
@@ -6559,6 +6559,16 @@
"integrity": "sha1-0CJTc662Uq3BvILklFM5qEJ1R3M=",
"dev": true
},
"lodash.uniqby": {
"version": "4.7.0",
"resolved": "https://registry.npmjs.org/lodash.uniqby/-/lodash.uniqby-4.7.0.tgz",
"integrity": "sha1-2ZwHpmnp5tJOE2Lf4mbGdhavEwI="
},
"lodash.uniqueid": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/lodash.uniqueid/-/lodash.uniqueid-4.0.1.tgz",
"integrity": "sha1-MmjyanyI5PSxdY1nknGBTjH6WyY="
},
"log-symbols": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-2.2.0.tgz",
+2
View File
@@ -27,6 +27,8 @@
"dependencies": {
"deepmerge": "^2.2.1",
"lodash.isplainobject": "^4.0.6",
"lodash.uniqby": "^4.7.0",
"lodash.uniqueid": "^4.0.1",
"object-assign": "^4.1.1"
},
"devDependencies": {
+7 -1
View File
@@ -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()
)
}
return result
}
+1
View File
@@ -53,6 +53,7 @@ export default function _getMetaInfo (options = {}) {
option: keyName,
deep: true,
metaTemplateKeyName,
tagIDKeyName,
contentKeyName,
arrayMerge (target, source) {
// we concat the arrays without merging objects contained in,