-
-
Notifications
You must be signed in to change notification settings - Fork 48
/
Copy pathinstallComponents.js
38 lines (30 loc) · 1002 Bytes
/
installComponents.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
global.installComponents = function (component, components) {
var options = typeof component.exports === 'function'
? component.exports.extendOptions
: component.options
if (typeof component.exports === 'function') {
options.components = component.exports.options.components
}
options.components = options.components || {}
for (var i in components) {
options.components[i] = options.components[i] || components[i]
}
if (options.functional) {
provideFunctionalComponents(component, options.components)
}
}
var functionalPatchKey = '_functionalComponents'
function provideFunctionalComponents(component, components) {
if (component.exports[functionalPatchKey]) {
return
}
component.exports[functionalPatchKey] = true
var render = component.exports.render
component.exports.render = function (h, vm) {
return render(h, Object.assign({}, vm, {
_c: function (n, a, b) {
return vm._c(components[n] || n, a, b)
}
}))
}
}