@@ -53,7 +53,9 @@ exports.extend = function (extendOptions) {
5353 Sub . extend = Super . extend
5454 // create asset registers, so extended classes
5555 // can have their private assets too.
56- createAssetRegisters ( Sub )
56+ config . _assetTypes . forEach ( function ( type ) {
57+ Sub [ type ] = Super [ type ]
58+ } )
5759 return Sub
5860}
5961
@@ -92,48 +94,26 @@ exports.use = function (plugin) {
9294}
9395
9496/**
95- * Define asset registration methods on a constructor.
97+ * Create asset registration methods with the following
98+ * signature:
9699 *
97- * @param {Function } Constructor
100+ * @param {String } id
101+ * @param {* } definition
98102 */
99103
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 ) {
127106 if ( ! definition ) {
128- return this . options . components [ id ]
107+ return this . options [ type + 's' ] [ id ]
129108 } else {
130- if ( _ . isPlainObject ( definition ) ) {
109+ if (
110+ type === 'component' &&
111+ _ . isPlainObject ( definition )
112+ ) {
131113 definition . name = id
132114 definition = _ . Vue . extend ( definition )
133115 }
134- this . options . components [ id ] = definition
116+ this . options [ type + 's' ] [ id ] = definition
135117 }
136118 }
137- }
138-
139- createAssetRegisters ( exports )
119+ } )
0 commit comments