Skip to content

Commit 55cd948

Browse files
committed
Checkboxradio: Fix label handling with jQuery 3.x
Fixes #15006 Closes jquerygh-1720
1 parent 21f7f25 commit 55cd948

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

ui/widgets/checkboxradio.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ $.widget( "ui.checkboxradio", [ $.ui.formResetMixin, {
6969

7070
// We need to get the label text but this may also need to make sure it does not contain the
7171
// input itself.
72-
this.label.contents().not( this.element ).each( function() {
72+
this.label.contents().not( this.element[ 0 ] ).each( function() {
7373

7474
// The label contents could be text, html, or a mix. We concat each element to get a
7575
// string representation of the label, without the input as part of it.
@@ -252,7 +252,15 @@ $.widget( "ui.checkboxradio", [ $.ui.formResetMixin, {
252252
_updateLabel: function() {
253253

254254
// Remove the contents of the label ( minus the icon, icon space, and input )
255-
this.label.contents().not( this.element.add( this.icon ).add( this.iconSpace ) ).remove();
255+
var contents = this.label.contents().not( this.element[ 0 ] );
256+
if ( this.icon ) {
257+
contents = contents.not( this.icon[ 0 ] );
258+
}
259+
if ( this.iconSpace ) {
260+
contents = contents.not( this.iconSpace[ 0 ] );
261+
}
262+
contents.remove();
263+
256264
this.label.append( this.options.label );
257265
},
258266

0 commit comments

Comments
 (0)