Skip to content

Commit

Permalink
fix: use computed prop (which uses caching) instead of calling the fn…
Browse files Browse the repository at this point in the history
… directly
  • Loading branch information
pimlie committed Sep 12, 2019
1 parent 631cc9c commit c344d60
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/shared/getComponentOption.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,19 @@ export function getComponentMetaInfo (options = {}, component) {
*/
export function getComponentOption (options = {}, component, result = {}) {
const { keyName } = options
const { $options, $children } = component
const { $metaInfo, $options, $children } = component

if (component._inactive) {
return result
}

// only collect option data if it exists
if ($options[keyName]) {
let data = $options[keyName]

// if option is a function, replace it with it's result
if (isFunction(data)) {
data = data.call(component)
}
// if $metaInfo exists then [keyName] was defined as a function
// and set to the computed prop $metaInfo in the mixin
// using the computed prop should be a small performance increase
// because Vue caches those internally
const data = $metaInfo || $options[keyName]

// ignore data if its not an object, then we keep our previous result
if (!isObject(data)) {
Expand Down

0 comments on commit c344d60

Please sign in to comment.