File tree Expand file tree Collapse file tree 2 files changed +20
-6
lines changed
test/unit/features/global-api Expand file tree Collapse file tree 2 files changed +20
-6
lines changed Original file line number Diff line number Diff line change @@ -4,13 +4,11 @@ import { toArray } from '../util/index'
44
55export function initUse ( Vue : GlobalAPI ) {
66 Vue . use = function ( plugin : Function | Object ) {
7- const cid = this . cid
8- if ( ! plugin . _installed ) {
9- plugin . _installed = { }
10- }
11- if ( plugin . _installed [ cid ] ) {
7+ const installedPlugins = ( this . _installedPlugins || ( this . _installedPlugins = [ ] ) )
8+ if ( installedPlugins . indexOf ( plugin ) > - 1 ) {
129 return this
1310 }
11+
1412 // additional parameters
1513 const args = toArray ( arguments , 1 )
1614 args . unshift ( this )
@@ -19,7 +17,7 @@ export function initUse (Vue: GlobalAPI) {
1917 } else if ( typeof plugin === 'function' ) {
2018 plugin . apply ( null , args )
2119 }
22- plugin . _installed [ cid ] = true
20+ installedPlugins . push ( plugin )
2321 return this
2422 }
2523}
Original file line number Diff line number Diff line change @@ -33,4 +33,20 @@ describe('Global API: use', () => {
3333 expect ( Vue . options . directives [ 'plugin-test' ] ) . toBeUndefined ( )
3434 expect ( Ctor . options . directives [ 'plugin-test' ] ) . toBe ( def )
3535 } )
36+
37+ // Github issue #5970
38+ it ( 'should work on multi version' , ( ) => {
39+ const Ctor1 = Vue . extend ( { } )
40+ const Ctor2 = Vue . extend ( { } )
41+
42+ Ctor1 . use ( pluginStub , options )
43+ expect ( Vue . options . directives [ 'plugin-test' ] ) . toBeUndefined ( )
44+ expect ( Ctor1 . options . directives [ 'plugin-test' ] ) . toBe ( def )
45+
46+ // multi version Vue Ctor with the same cid
47+ Ctor2 . cid = Ctor1 . cid
48+ Ctor2 . use ( pluginStub , options )
49+ expect ( Vue . options . directives [ 'plugin-test' ] ) . toBeUndefined ( )
50+ expect ( Ctor2 . options . directives [ 'plugin-test' ] ) . toBe ( def )
51+ } )
3652} )
You can’t perform that action at this time.
0 commit comments