Skip to content

Commit 010f5f9

Browse files
committed
Tooltip: Fix re-enabling of delegated tooltips
Fixes #14950 Closes jquerygh-1699
1 parent 3585b7a commit 010f5f9

File tree

2 files changed

+29
-9
lines changed

2 files changed

+29
-9
lines changed

tests/unit/tooltip/methods.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,20 @@ QUnit.test( "enable/disable", function( assert ) {
9494
$.fx.off = false;
9595
} );
9696

97+
QUnit.test( "enable/disable delegated", function( assert ) {
98+
assert.expect( 1 );
99+
var element = $( "#qunit-fixture" ).tooltip();
100+
var tooltipped = $( "#tooltipped1" );
101+
102+
element.tooltip( "disable" );
103+
element.tooltip( "enable" );
104+
105+
tooltipped.trigger( "mouseover" );
106+
assert.equal( $( ".ui-tooltip" ).length, 1, "open" );
107+
108+
element.tooltip( "destroy" );
109+
} );
110+
97111
QUnit.test( "widget", function( assert ) {
98112
assert.expect( 2 );
99113
var element = $( "#tooltipped1" ).tooltip(),

ui/widgets/tooltip.js

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,8 @@ $.widget( "ui.tooltip", {
114114
} )
115115
.appendTo( this.document[ 0 ].body );
116116
this._addClass( this.liveRegion, null, "ui-helper-hidden-accessible" );
117+
118+
this.disabledTitles = $( [] );
117119
},
118120

119121
_setOption: function( key, value ) {
@@ -143,25 +145,29 @@ $.widget( "ui.tooltip", {
143145
} );
144146

145147
// Remove title attributes to prevent native tooltips
146-
this.element.find( this.options.items ).addBack().each( function() {
147-
var element = $( this );
148-
if ( element.is( "[title]" ) ) {
149-
element
150-
.data( "ui-tooltip-title", element.attr( "title" ) )
151-
.removeAttr( "title" );
152-
}
153-
} );
148+
this.disabledTitles = this.disabledTitles.add(
149+
this.element.find( this.options.items ).addBack()
150+
.filter( function() {
151+
var element = $( this );
152+
if ( element.is( "[title]" ) ) {
153+
return element
154+
.data( "ui-tooltip-title", element.attr( "title" ) )
155+
.removeAttr( "title" );
156+
}
157+
} )
158+
);
154159
},
155160

156161
_enable: function() {
157162

158163
// restore title attributes
159-
this.element.find( this.options.items ).addBack().each( function() {
164+
this.disabledTitles.each( function() {
160165
var element = $( this );
161166
if ( element.data( "ui-tooltip-title" ) ) {
162167
element.attr( "title", element.data( "ui-tooltip-title" ) );
163168
}
164169
} );
170+
this.disabledTitles = $( [] );
165171
},
166172

167173
open: function( event ) {

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy