Skip to content

Commit

Permalink
Simplified check for labels as parents of inputs.
Browse files Browse the repository at this point in the history
  • Loading branch information
Wilto committed Mar 26, 2012
1 parent 6fa00e7 commit 93eaaf1
Showing 1 changed file with 2 additions and 14 deletions.
16 changes: 2 additions & 14 deletions js/jquery.mobile.forms.checkboxradio.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ $.widget( "mobile.checkboxradio", $.mobile.widget, {
},
// NOTE: Windows Phone could not find the label through a selector
// filter works though.
label = $( input ).closest( "form,fieldset,:jqmData(role='page'),:jqmData(role='dialog')" ).find( "label" ).filter( "[for='" + input[0].id + "']" ),
parentLabel = $( input ).closest( "label" ),
label = parentLabel.length ? parentLabel : $( input ).closest( "form,fieldset,:jqmData(role='page'),:jqmData(role='dialog')" ).find( "label" ).filter( "[for='" + input[0].id + "']" ),
inputtype = input[0].type,
mini = inheritAttr( input, "mini" ),
checkedState = inputtype + "-on",
Expand All @@ -42,19 +43,6 @@ $.widget( "mobile.checkboxradio", $.mobile.widget, {
return;
}

// check for <label><input /></label> structure
if (!label.length) {
label = $(input).closest('label');
// <label> is only implicitly for its first label-able descendant
if (!label.find('button, input[type!="hidden"], keygen, meter, output, progress, select, textarea').first().is(input)) {
label = $('');
}
}

if( !label.length ){
this.raise( inputtype + " inputs require a label for enhancement" );
}

// Expose for other methods
$.extend( this, {
label: label,
Expand Down

0 comments on commit 93eaaf1

Please sign in to comment.