Skip to content

Commit 1c17f9c

Browse files
committed
refactor: 精简代码
1 parent 744b516 commit 1c17f9c

File tree

1 file changed

+4
-15
lines changed

1 file changed

+4
-15
lines changed

src/BootstrapBlazor/Components/Button/DialButton.razor.js

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,9 @@ export function init(id) {
1616
EventHandler.on(button, 'click', () => {
1717
toggle(el, list)
1818
})
19-
20-
const module = registerBootstrapBlazorModule('DialButton', {
21-
hooked: false,
22-
items: [],
23-
registerClosePopupHandler: function () {
24-
if (this.hooked === false) {
25-
this.hooked = true;
26-
EventHandler.on(document, 'click', closePopup);
27-
}
28-
}
19+
registerBootstrapBlazorModule('DialButton', id, () => {
20+
EventHandler.on(document, 'click', closePopup);
2921
});
30-
module.registerClosePopupHandler();
31-
module.items.push(id);
3222
}
3323

3424
export function update(id) {
@@ -56,10 +46,9 @@ export function dispose(id) {
5646
}
5747

5848
const { DialButton } = window.BootstrapBlazor;
59-
DialButton.items.pop(id)
60-
if (DialButton.items.length === 0) {
49+
DialButton.dispose(id, () => {
6150
EventHandler.off(document, 'click', closePopup)
62-
}
51+
});
6352
}
6453

6554
const toggle = (el, list) => {

0 commit comments

Comments
 (0)