Skip to content

Checkboxradio: Fix label handling with jQuery 3.x #1720

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions ui/widgets/checkboxradio.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ $.widget( "ui.checkboxradio", [ $.ui.formResetMixin, {

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

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

// Remove the contents of the label ( minus the icon, icon space, and input )
this.label.contents().not( this.element.add( this.icon ).add( this.iconSpace ) ).remove();
var contents = this.label.contents().not( this.element[ 0 ] );
if ( this.icon ) {
contents = contents.not( this.icon[ 0 ] );
}
if ( this.iconSpace ) {
contents = contents.not( this.iconSpace[ 0 ] );
}
contents.remove();

this.label.append( this.options.label );
},

Expand Down