@@ -85,7 +85,6 @@ export default Base.extend({
8585 interactive : true ,
8686 onHide : this . _onHide . bind ( this ) ,
8787 onShow : this . _onShow . bind ( this ) ,
88- onMount : this . _onMount . bind ( this ) ,
8988 trigger : "click" ,
9089 } ;
9190
@@ -262,34 +261,16 @@ export default Base.extend({
262261 } ,
263262
264263 async _onShow ( ) {
265- if ( this . options . closing !== "auto" && this . options . trigger === "hover" ) {
266- // no auto-close when hovering when closing mode is "sticky" or "close-button".
267- this . tippy . setProps ( { trigger : "click" } ) ;
268- }
264+ const tippy_classes = [ ] ;
269265
270- if ( this . options . markInactive ) {
271- this . el . classList . remove ( this . inactive_class ) ;
272- this . el . classList . add ( this . active_class ) ;
273- }
266+ // Group DOM manipulations
274267
275- if ( this . options . source === "ajax" ) {
276- await this . _get_content ( ) ;
277- // Also initialize content.
278- // Due to asynchronous ``_onShow`` the content might not be
279- // available before ``_onMount``.
280- this . _initialize_content ( ) ;
268+ if ( this . options . class ) {
269+ tippy_classes . push ( ...this . options . class . split ( " " ) ) ;
281270 }
282- } ,
283271
284- _onMount ( ) {
285- // Notify parent patterns about injected content.
286- // Do not call pat-inject's handler, because all necessary
287- // initialization after injection is done here.
288- $ ( this . tippy . popper ) . trigger ( "patterns-injected" , [
289- { skipPatInjectHandler : true } ,
290- this . el ,
291- this . tippy . popper ,
292- ] ) ;
272+ // Add a generic non-tippy related class to identify the tooltip container
273+ tippy_classes . push ( "tooltip-container" ) ;
293274
294275 if ( this . options . closing === "close-button" ) {
295276 // First, remove previously automatically added close buttons.
@@ -298,7 +279,7 @@ export default Base.extend({
298279 for ( const close_button of this . tippy . popper . querySelectorAll (
299280 ".pat-tooltip--close-button"
300281 ) ) {
301- close_button . parentNode . removeChild ( close_button ) ;
282+ close_button . remove ( ) ;
302283 }
303284
304285 const close_button = document . createElement ( "button" ) ;
@@ -307,18 +288,34 @@ export default Base.extend({
307288 content . parentNode . insertBefore ( close_button , content ) ;
308289 }
309290
310- if ( this . options . class ) {
311- for ( let class_ of this . options . class . split ( " " ) ) {
312- this . tippy . popper . classList . add ( class_ ) ;
313- }
291+ // Store reference to method for closing panels on the tooltip element instance.
292+ tippy_classes . push ( "has-close-panel" ) ;
293+ dom . set_data ( this . tippy . popper , "close_panel" , this . hide . bind ( this ) ) ;
294+
295+ this . tippy . popper . classList . add ( ...tippy_classes ) ;
296+
297+ if ( this . options . markInactive ) {
298+ this . el . classList . remove ( this . inactive_class ) ;
299+ this . el . classList . add ( this . active_class ) ;
314300 }
315301
316- // Add a generic non-tippy related class to identify the tooltip container
317- this . tippy . popper . classList . add ( "tooltip-container" ) ;
302+ if ( this . options . closing !== "auto" && this . options . trigger === "hover" ) {
303+ // no auto-close when hovering when closing mode is "sticky" or "close-button".
304+ this . tippy . setProps ( { trigger : "click" } ) ;
305+ }
318306
319- // Store reference to method for closing panels on the tooltip element instance.
320- this . tippy . popper . classList . add ( "has-close-panel" ) ;
321- dom . set_data ( this . tippy . popper , "close_panel" , this . hide . bind ( this ) ) ;
307+ if ( this . options . source === "ajax" ) {
308+ await this . _get_content ( ) ;
309+ }
310+
311+ // Notify parent patterns about injected content.
312+ // Do not call pat-inject's handler, because all necessary
313+ // initialization after injection is done here.
314+ $ ( this . tippy . popper ) . trigger ( "patterns-injected" , [
315+ { skipPatInjectHandler : true } ,
316+ this . el ,
317+ this . tippy . popper ,
318+ ] ) ;
322319
323320 this . _initialize_content ( ) ;
324321 } ,
0 commit comments