fix(runtime-core): fix error when passed plugin is undefined (#502)
This commit is contained in:
committed by
Evan You
parent
cfa7efe4e8
commit
fbcc47841b
@@ -102,7 +102,7 @@ export function createAppAPI<HostNode, HostElement>(
|
||||
} else if (isFunction(plugin)) {
|
||||
installedPlugins.add(plugin)
|
||||
plugin(app)
|
||||
} else if (isFunction(plugin.install)) {
|
||||
} else if (plugin && isFunction(plugin.install)) {
|
||||
installedPlugins.add(plugin)
|
||||
plugin.install(app)
|
||||
} else if (__DEV__) {
|
||||
@@ -137,15 +137,12 @@ export function createAppAPI<HostNode, HostElement>(
|
||||
}
|
||||
if (!component) {
|
||||
return context.components[name]
|
||||
} else {
|
||||
if (__DEV__ && context.components[name]) {
|
||||
warn(
|
||||
`Component "${name}" has already been registered in target app.`
|
||||
)
|
||||
}
|
||||
context.components[name] = component
|
||||
return app
|
||||
}
|
||||
if (__DEV__ && context.components[name]) {
|
||||
warn(`Component "${name}" has already been registered in target app.`)
|
||||
}
|
||||
context.components[name] = component
|
||||
return app
|
||||
},
|
||||
|
||||
directive(name: string, directive?: Directive) {
|
||||
@@ -155,15 +152,12 @@ export function createAppAPI<HostNode, HostElement>(
|
||||
|
||||
if (!directive) {
|
||||
return context.directives[name] as any
|
||||
} else {
|
||||
if (__DEV__ && context.directives[name]) {
|
||||
warn(
|
||||
`Directive "${name}" has already been registered in target app.`
|
||||
)
|
||||
}
|
||||
context.directives[name] = directive
|
||||
return app
|
||||
}
|
||||
if (__DEV__ && context.directives[name]) {
|
||||
warn(`Directive "${name}" has already been registered in target app.`)
|
||||
}
|
||||
context.directives[name] = directive
|
||||
return app
|
||||
},
|
||||
|
||||
mount(
|
||||
|
||||
Reference in New Issue
Block a user