@@ -86,7 +86,7 @@ var defaults = {
8686 hasTransitions : transitionSupport ( ) ,
8787 IE : false ,
8888 // don't set manually, it will be updated by a build task after the manifest
89- semVer : '4.0.2 ' ,
89+ semVer : '4.0.4 ' ,
9090 window : win
9191 } ,
9292 core = function ( ) {
@@ -679,7 +679,7 @@ $.Tooltipster.prototype = {
679679 $document = $ ( env . window . document ) ,
680680 $window = $ ( env . window ) ,
681681 $parent = $target ,
682- // some useful properties of important elements
682+ // some useful properties of important elements
683683 geo = {
684684 // available space for the tooltip, see down below
685685 available : {
@@ -1346,7 +1346,7 @@ $.Tooltipster.prototype = {
13461346 // if the origin or tooltip elements have been removed.
13471347 // Note: we could destroy the instance now if the origin has
13481348 // been removed but we'll leave that task to our garbage collector
1349- if ( ! bodyContains ( self . _$origin ) || ! bodyContains ( self . __namespace ) ) {
1349+ if ( ! bodyContains ( self . _$origin ) || ! bodyContains ( self . _$tooltip ) ) {
13501350 self . _close ( ) ;
13511351 }
13521352 // if everything is alright
@@ -2773,7 +2773,7 @@ $.Tooltipster.prototype = {
27732773
27742774 // if the tooltip has not been removed from DOM manually (or if it
27752775 // has been detached on purpose)
2776- if ( bodyContains ( self . __namespace ) || tooltipIsDetached ) {
2776+ if ( bodyContains ( self . _$tooltip ) || tooltipIsDetached ) {
27772777
27782778 if ( ! tooltipIsDetached ) {
27792779 // detach in case the tooltip overflows the window and adds
@@ -3236,14 +3236,17 @@ function areEqual(a,b) {
32363236/**
32373237 * A fast function to check if an element is still in the DOM. It
32383238 * tries to use an id as ids are indexed by the browser, or falls
3239- * back to jQuery's `contains` method.
3239+ * back to jQuery's `contains` method. May fail if two elements
3240+ * have the same id, but so be it
32403241 *
3241- * @param {string| object } ref An id or a jQuery-wrapped HTML element
3242+ * @param {object } $obj A jQuery-wrapped HTML element
32423243 * @return {boolean }
32433244 */
3244- function bodyContains ( ref ) {
3245- var id = ( typeof ref === 'string' ) ? ref : ref . attr ( 'id' ) ;
3246- return id ? ! ! env . window . document . getElementById ( id ) : $ . contains ( env . window . document . body , ref [ 0 ] ) ;
3245+ function bodyContains ( $obj ) {
3246+ var id = $obj . attr ( 'id' ) ,
3247+ el = id ? env . window . document . getElementById ( id ) : null ;
3248+ // must also check that the element with the id is the one we want
3249+ return el ? el === $obj [ 0 ] : $ . contains ( env . window . document . body , $obj [ 0 ] ) ;
32473250}
32483251
32493252// detect IE versions for dirty fixes
0 commit comments