@@ -131,6 +131,17 @@ const Popover = {
131131 }
132132 }
133133
134+
135+ EventHandler . on ( el , 'show.bs.popover' , showPopover )
136+ EventHandler . on ( el , 'inserted.bs.popover' , insertedPopover )
137+ EventHandler . on ( el , 'hide.bs.popover' , hidePopover )
138+ EventHandler . on ( el , 'click' , popover . toggleClass , active )
139+ EventHandler . on ( popover . toggleMenu , 'click' , '.dropdown-item' , e => {
140+ if ( popover . popover . _config . autoClose !== 'outside' ) {
141+ popover . hide ( )
142+ }
143+ } )
144+
134145 popover . closePopover = e => {
135146 const selector = `.${ popover . class } .show` ;
136147 const el = e . target ;
@@ -150,31 +161,9 @@ const Popover = {
150161 }
151162 } ) ;
152163 }
153-
154- EventHandler . on ( el , 'show.bs.popover' , showPopover )
155- EventHandler . on ( el , 'inserted.bs.popover' , insertedPopover )
156- EventHandler . on ( el , 'hide.bs.popover' , hidePopover )
157- EventHandler . on ( el , 'click' , popover . toggleClass , active )
158- EventHandler . on ( popover . toggleMenu , 'click' , '.dropdown-item' , e => {
159- if ( popover . popover . _config . autoClose !== 'outside' ) {
160- popover . hide ( )
161- }
162- } )
163-
164- const module = registerBootstrapBlazorModule ( 'Popover' , {
165- handle : false ,
166- items : [ ] ,
167- registerClosePopupHandler : function ( ) {
168- if ( this . handle === false ) {
169- this . handle = true ;
170-
171- EventHandler . on ( document , 'click' , popover . closePopover ) ;
172- }
173- }
164+ registerBootstrapBlazorModule ( 'Popover' , el , ( ) => {
165+ EventHandler . on ( document , 'click' , popover . closePopover ) ;
174166 } ) ;
175- module . registerClosePopupHandler ( ) ;
176- module . items . push ( popover ) ;
177-
178167
179168 // update handler
180169 if ( popover . toggleMenu ) {
@@ -218,10 +207,9 @@ const Popover = {
218207 EventHandler . off ( popover . toggleMenu , 'click' , '.dropdown-item' )
219208
220209 const { Popover } = window . BootstrapBlazor ;
221- Popover . items . pop ( popover )
222- if ( Popover . items . length === 0 ) {
223- EventHandler . off ( document , 'click' , popover . closePopover )
224- }
210+ Popover . dispose ( popover , ( ) => {
211+ EventHandler . off ( document , 'click' , popover . closePopover ) ;
212+ } ) ;
225213 }
226214 else {
227215 EventHandler . off ( popover . el , 'show.bs.dropdown' )
0 commit comments