@@ -17,9 +17,9 @@ var defaults = {
1717 IEmin : 6 ,
1818 interactive : false ,
1919 multiple : false ,
20- // must be 'body' for now, or an element positioned at (0, 0)
20+ // must be 'body' for now (default) , or an element positioned at (0, 0)
2121 // in the document, typically like the very top views of an app.
22- parent : 'body' ,
22+ parent : null ,
2323 plugins : [ 'sideTip' ] ,
2424 repositionOnScroll : false ,
2525 restoration : 'none' ,
@@ -546,7 +546,7 @@ $.Tooltipster.prototype = {
546546
547547 // to detect swiping
548548 if ( env . hasTouchCapability ) {
549- $ ( ' body' ) . on ( 'touchmove.' + self . __namespace + '-triggerOpen' , function ( event ) {
549+ $ ( env . window . document . body ) . on ( 'touchmove.' + self . __namespace + '-triggerOpen' , function ( event ) {
550550 self . _touchRecordEvent ( event ) ;
551551 } ) ;
552552 }
@@ -941,7 +941,10 @@ $.Tooltipster.prototype = {
941941 }
942942
943943 // determine the future parent
944- if ( typeof this . __options . parent == 'string' ) {
944+ if ( this . __options . parent === null ) {
945+ this . __options . parent = $ ( env . window . document . body ) ;
946+ }
947+ else if ( typeof this . __options . parent == 'string' ) {
945948 this . __options . parent = $ ( this . __options . parent ) ;
946949 }
947950
@@ -1519,7 +1522,7 @@ $.Tooltipster.prototype = {
15191522 // clear the array to prevent memory leaks
15201523 self . __$originParents = null ;
15211524
1522- $ ( ' body' ) . off ( '.' + self . __namespace + '-triggerClose' ) ;
1525+ $ ( env . window . document . body ) . off ( '.' + self . __namespace + '-triggerClose' ) ;
15231526
15241527 self . _$origin . off ( '.' + self . __namespace + '-triggerClose' ) ;
15251528
@@ -1971,7 +1974,7 @@ $.Tooltipster.prototype = {
19711974 eventNames += 'touchend.' + self . __namespace + '-triggerClose' ;
19721975 }
19731976
1974- $ ( ' body' ) . on ( eventNames , function ( event ) {
1977+ $ ( env . window . document . body ) . on ( eventNames , function ( event ) {
19751978
19761979 if ( self . _touchIsMeaningfulEvent ( event ) ) {
19771980
@@ -1986,7 +1989,7 @@ $.Tooltipster.prototype = {
19861989 // needed to detect and ignore swiping
19871990 if ( self . __options . triggerClose . tap && env . hasTouchCapability ) {
19881991
1989- $ ( ' body' ) . on ( 'touchstart.' + self . __namespace + '-triggerClose' , function ( event ) {
1992+ $ ( env . window . document . body ) . on ( 'touchstart.' + self . __namespace + '-triggerClose' , function ( event ) {
19901993 self . _touchRecordEvent ( event ) ;
19911994 } ) ;
19921995 }
@@ -2485,7 +2488,7 @@ $.Tooltipster.prototype = {
24852488 . off ( '.' + self . __namespace + '-triggerOpen' ) ;
24862489
24872490 // remove the touch listener
2488- $ ( ' body' ) . off ( '.' + self . __namespace + '-triggerOpen' ) ;
2491+ $ ( env . window . document . body ) . off ( '.' + self . __namespace + '-triggerOpen' ) ;
24892492
24902493 var ns = self . _$origin . data ( 'tooltipster-ns' ) ;
24912494
@@ -3070,7 +3073,7 @@ Ruler.prototype = {
30703073
30713074 this . $container = $ ( '<div class="tooltipster-ruler"></div>' )
30723075 . append ( this . __$tooltip )
3073- . appendTo ( ' body' ) ;
3076+ . appendTo ( env . window . document . body ) ;
30743077 } ,
30753078
30763079 /**
0 commit comments