Skip to content

Commit f56a3d2

Browse files
committed
refactor: 优化 registerBootstrapBlazorModule 方法
1 parent a32b88e commit f56a3d2

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/BootstrapBlazor/wwwroot/modules/utility.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -822,17 +822,21 @@ export function registerBootstrapBlazorModule(name, identifier, callback) {
822822
}
823823
if (this._init === false) {
824824
this._init = true;
825-
cb(this);
825+
if (isFunction(cb)) {
826+
cb(this);
827+
}
826828
}
827829
return this;
828830
},
829831
dispose: function (id, cb) {
830832
if (id) {
831833
this._items = this._items.filter(item => item !== id);
832834
}
833-
if (this._items.length === 0 && cb) {
835+
if (this._items.length === 0) {
834836
this._init = false;
835-
cb(this);
837+
if (isFunction(cb)) {
838+
cb(this);
839+
}
836840
}
837841
}
838842
};

0 commit comments

Comments
 (0)