Skip to content

Commit 6c0e762

Browse files
committed
refactor: 精简代码
1 parent 8d9c2df commit 6c0e762

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

src/BootstrapBlazor/wwwroot/modules/utility.js

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -813,25 +813,22 @@ export function registerBootstrapBlazorModule(name, identifier, callback) {
813813
window.BootstrapBlazor[name] ??= {
814814
_init: false,
815815
_items: [],
816-
register: function (identifier, callback) {
817-
if (identifier) {
818-
this._items.push(identifier);
816+
register: function (id, cb) {
817+
if (id) {
818+
this._items.push(id);
819819
}
820820
if (this._init === false) {
821821
this._init = true;
822-
callback();
822+
cb();
823823
}
824824
return this;
825825
},
826-
dispose: function (identifier, callback) {
827-
if (identifier) {
828-
const index = this._items.indexOf(identifier);
829-
if (index > -1) {
830-
this._items.splice(index, 1);
831-
}
826+
dispose: function (id, cb) {
827+
if (id) {
828+
this._items = this._items.filter(item => item !== id);
832829
}
833-
if (this._items.length === 0) {
834-
callback();
830+
if (this._items.length === 0 && cb) {
831+
cb();
835832
}
836833
}
837834
};

0 commit comments

Comments
 (0)