Skip to content

Commit c344d60

Browse files
committed
fix: use computed prop (which uses caching) instead of calling the fn directly
1 parent 631cc9c commit c344d60

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

src/shared/getComponentOption.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,19 @@ export function getComponentMetaInfo (options = {}, component) {
2323
*/
2424
export function getComponentOption (options = {}, component, result = {}) {
2525
const { keyName } = options
26-
const { $options, $children } = component
26+
const { $metaInfo, $options, $children } = component
2727

2828
if (component._inactive) {
2929
return result
3030
}
3131

3232
// only collect option data if it exists
3333
if ($options[keyName]) {
34-
let data = $options[keyName]
35-
36-
// if option is a function, replace it with it's result
37-
if (isFunction(data)) {
38-
data = data.call(component)
39-
}
34+
// if $metaInfo exists then [keyName] was defined as a function
35+
// and set to the computed prop $metaInfo in the mixin
36+
// using the computed prop should be a small performance increase
37+
// because Vue caches those internally
38+
const data = $metaInfo || $options[keyName]
4039

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

0 commit comments

Comments
 (0)