A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/vuejs/vue/commit/049f317 below:

support plugin with multi version vue (#5985) · vuejs/vue@049f317 · GitHub

File tree Expand file treeCollapse file tree 2 files changed

+20

-6

lines changed

Filter options

Expand file treeCollapse 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'

4 4 5 5

export function initUse (Vue: GlobalAPI) {

6 6

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) {

12 9

return this

13 10

}

11 + 14 12

// additional parameters

15 13

const args = toArray(arguments, 1)

16 14

args.unshift(this)

@@ -19,7 +17,7 @@ export function initUse (Vue: GlobalAPI) {

19 17

} else if (typeof plugin === 'function') {

20 18

plugin.apply(null, args)

21 19

}

22 -

plugin._installed[cid] = true

20 +

installedPlugins.push(plugin)

23 21

return this

24 22

}

25 23

}

Original file line number Diff line number Diff line change

@@ -33,4 +33,20 @@ describe('Global API: use', () => {

33 33

expect(Vue.options.directives['plugin-test']).toBeUndefined()

34 34

expect(Ctor.options.directives['plugin-test']).toBe(def)

35 35

})

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 +

})

36 52

})

You can’t perform that action at this time.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4