const PluginB: Plugin = {
install: app => app.provide('bar', 2)
}
+ const PluginC: any = undefined
const app = createApp()
app.use(PluginA)
expect(
`Plugin has already been applied to target app`
).toHaveBeenWarnedTimes(1)
+
+ app.use(PluginC)
+ expect(
+ `A plugin must either be a function or an object with an "install" ` +
+ `function.`
+ ).toHaveBeenWarnedTimes(1)
})
test('config.errorHandler', () => {
} 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__) {
}
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) {
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(