File tree Expand file tree Collapse file tree 1 file changed +16
-9
lines changed Expand file tree Collapse file tree 1 file changed +16
-9
lines changed Original file line number Diff line number Diff line change @@ -21,8 +21,8 @@ exports._applyFilter = function (id, args) {
21
21
* Resolve a component, depending on whether the component
22
22
* is defined normally or using an async factory function.
23
23
* Resolves synchronously if already resolved, otherwise
24
- * resolves asynchronously and replaces the factory with
25
- * the resolved component .
24
+ * resolves asynchronously and caches the resolved
25
+ * constructor on the factory .
26
26
*
27
27
* @param {String } id
28
28
* @param {Function } cb
@@ -34,14 +34,21 @@ exports._resolveComponent = function (id, cb) {
34
34
_ . assertAsset ( raw , 'component' , id )
35
35
// async component factory
36
36
if ( ! raw . options ) {
37
- raw ( function resolve ( res ) {
38
- if ( _ . isPlainObject ( res ) ) {
39
- res = _ . Vue . extend ( res )
40
- }
41
- registry [ id ] = res
42
- cb ( res )
43
- } )
37
+ if ( raw . resolved ) {
38
+ // cached
39
+ cb ( raw . resolved )
40
+ } else {
41
+ raw ( function resolve ( res ) {
42
+ if ( _ . isPlainObject ( res ) ) {
43
+ res = _ . Vue . extend ( res )
44
+ }
45
+ // cache resolved
46
+ raw . resolved = res
47
+ cb ( res )
48
+ } )
49
+ }
44
50
} else {
51
+ // normal component
45
52
cb ( raw )
46
53
}
47
54
}
You can’t perform that action at this time.
0 commit comments