2
0
mirror of https://github.com/tenrok/vue-meta.git synced 2026-06-24 04:40:34 +03:00

fix: use computed prop (which uses caching) instead of calling the fn directly

This commit is contained in:
pimlie
2019-09-12 15:20:13 +02:00
parent 631cc9c9c9
commit c344d60d5f
+6 -7
View File
@@ -23,7 +23,7 @@ export function getComponentMetaInfo (options = {}, component) {
*/ */
export function getComponentOption (options = {}, component, result = {}) { export function getComponentOption (options = {}, component, result = {}) {
const { keyName } = options const { keyName } = options
const { $options, $children } = component const { $metaInfo, $options, $children } = component
if (component._inactive) { if (component._inactive) {
return result return result
@@ -31,12 +31,11 @@ export function getComponentOption (options = {}, component, result = {}) {
// only collect option data if it exists // only collect option data if it exists
if ($options[keyName]) { if ($options[keyName]) {
let data = $options[keyName] // if $metaInfo exists then [keyName] was defined as a function
// and set to the computed prop $metaInfo in the mixin
// if option is a function, replace it with it's result // using the computed prop should be a small performance increase
if (isFunction(data)) { // because Vue caches those internally
data = data.call(component) const data = $metaInfo || $options[keyName]
}
// ignore data if its not an object, then we keep our previous result // ignore data if its not an object, then we keep our previous result
if (!isObject(data)) { if (!isObject(data)) {