File tree 2 files changed +25
-5
lines changed
test/unit/features/global-api
2 files changed +25
-5
lines changed Original file line number Diff line number Diff line change @@ -319,11 +319,14 @@ export function resolveAsset (
319
319
return
320
320
}
321
321
const assets = options [ type ]
322
- const res = assets [ id ] ||
323
- // camelCase ID
324
- assets [ camelize ( id ) ] ||
325
- // Pascal Case ID
326
- assets [ capitalize ( camelize ( id ) ) ]
322
+ // check local registration variations first
323
+ if ( hasOwn ( assets , id ) ) return assets [ id ]
324
+ const camelizedId = camelize ( id )
325
+ if ( hasOwn ( assets , camelizedId ) ) return assets [ camelizedId ]
326
+ const PascalCaseId = capitalize ( camelizedId )
327
+ if ( hasOwn ( assets , PascalCaseId ) ) return assets [ PascalCaseId ]
328
+ // fallback to prototype chain
329
+ const res = assets [ id ] || assets [ camelizedId ] || assets [ PascalCaseId ]
327
330
if ( process . env . NODE_ENV !== 'production' && warnMissing && ! res ) {
328
331
warn (
329
332
'Failed to resolve ' + type . slice ( 0 , - 1 ) + ': ' + id ,
Original file line number Diff line number Diff line change @@ -48,4 +48,21 @@ describe('Global API: assets', () => {
48
48
// extended registration should not pollute global
49
49
expect ( Vue . options . components . test ) . toBeUndefined ( )
50
50
} )
51
+
52
+ // #4434
53
+ it ( 'local registration should take priority regardless of naming convention' , ( ) => {
54
+ Vue . component ( 'x-foo' , {
55
+ template : '<span>global</span>'
56
+ } )
57
+ const vm = new Vue ( {
58
+ components : {
59
+ xFoo : {
60
+ template : '<span>local</span>'
61
+ }
62
+ } ,
63
+ template : '<div><x-foo></x-foo></div>'
64
+ } ) . $mount ( )
65
+ expect ( vm . $el . textContent ) . toBe ( 'local' )
66
+ delete Vue . options . components [ 'x-foo' ]
67
+ } )
51
68
} )
You can’t perform that action at this time.
0 commit comments