fix: 修复 registerAddon 函数

This commit is contained in:
力皓 2020-12-02 16:32:56 +08:00
parent 76c4a542bf
commit 309920a07a
2 changed files with 4 additions and 7 deletions

View File

@ -17,6 +17,7 @@ module.exports = {
collectCoverageFrom: [
'src/**/*.{ts,tsx}',
'!src/**/*.d.ts',
'!src/icons',
'!**/node_modules/**',
'!**/vendor/**',
],

View File

@ -584,14 +584,10 @@ export class DocumentModel {
if (['id', 'params', 'layout'].indexOf(name) > -1) {
throw new Error('addon name cannot be id, params, layout');
}
const i = this._addons?.findIndex((item) => item.name === name);
if (i > -1) {
this._addons?.splice(i, 1);
if (this._addons[name]) {
throw new Error(`node addon ${name} exists`);
}
this._addons?.push({
exportData,
name,
});
this._addons[name] = exportData;
}