@@ -53,7 +53,9 @@ exports.extend = function (extendOptions) {
53
53
Sub . extend = Super . extend
54
54
// create asset registers, so extended classes
55
55
// can have their private assets too.
56
- createAssetRegisters ( Sub )
56
+ config . _assetTypes . forEach ( function ( type ) {
57
+ Sub [ type ] = Super [ type ]
58
+ } )
57
59
return Sub
58
60
}
59
61
@@ -92,48 +94,26 @@ exports.use = function (plugin) {
92
94
}
93
95
94
96
/**
95
- * Define asset registration methods on a constructor.
97
+ * Create asset registration methods with the following
98
+ * signature:
96
99
*
97
- * @param {Function } Constructor
100
+ * @param {String } id
101
+ * @param {* } definition
98
102
*/
99
103
100
- function createAssetRegisters ( Constructor ) {
101
-
102
- /* Asset registration methods share the same signature:
103
- *
104
- * @param {String } id
105
- * @param {* } definition
106
- */
107
-
108
- config . _assetTypes . forEach ( function ( type ) {
109
- Constructor [ type ] = function ( id , definition ) {
110
- if ( ! definition ) {
111
- return this . options [ type + 's' ] [ id ]
112
- } else {
113
- this . options [ type + 's' ] [ id ] = definition
114
- }
115
- }
116
- } )
117
-
118
- /**
119
- * Component registration needs to automatically invoke
120
- * Vue.extend on object values.
121
- *
122
- * @param {String } id
123
- * @param {Object|Function } definition
124
- */
125
-
126
- Constructor . component = function ( id , definition ) {
104
+ config . _assetTypes . forEach ( function ( type ) {
105
+ exports [ type ] = function ( id , definition ) {
127
106
if ( ! definition ) {
128
- return this . options . components [ id ]
107
+ return this . options [ type + 's' ] [ id ]
129
108
} else {
130
- if ( _ . isPlainObject ( definition ) ) {
109
+ if (
110
+ type === 'component' &&
111
+ _ . isPlainObject ( definition )
112
+ ) {
131
113
definition . name = id
132
114
definition = _ . Vue . extend ( definition )
133
115
}
134
- this . options . components [ id ] = definition
116
+ this . options [ type + 's' ] [ id ] = definition
135
117
}
136
118
}
137
- }
138
-
139
- createAssetRegisters ( exports )
119
+ } )
0 commit comments