const root = nodeOps.createElement('div')
app.mount(Root, root)
expect(serializeInner(root)).toBe(`1,2`)
+
+ app.use(PluginA)
+ expect(
+ `Plugin has already been applied to target app`
+ ).toHaveBeenWarnedTimes(1)
})
test('config.errorHandler', () => {
): () => App<HostElement> {
return function createApp(): App {
const context = createAppContext()
+ const installedPlugins = new Set()
let isMounted = false
},
use(plugin: Plugin) {
- if (isFunction(plugin)) {
+ if (installedPlugins.has(plugin)) {
+ __DEV__ && warn(`Plugin has already been applied to target app.`)
+ } else if (isFunction(plugin)) {
+ installedPlugins.add(plugin)
plugin(app)
} else if (isFunction(plugin.install)) {
+ installedPlugins.add(plugin)
plugin.install(app)
} else if (__DEV__) {
warn(