Permalink
Browse files

fix checkboxradio to cope with <label><input /></label> and add new unit

test
  • Loading branch information...
jokeyrhyme authored and Wilto committed Mar 24, 2012
1 parent 3120f53 commit cf21c53520a60a689d57c3187daba1cf25f160b5
@@ -42,6 +42,15 @@ $.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" );
}
@@ -129,7 +129,7 @@
ok( !$("input.should-be-native").parent().is("div.ui-checkbox") );
});
test( "Elements with “data-mini='true' should have “ui-mini” class attached to enhanced element.", function(){
test( "Elements with “data-mini='true'� should have “ui-mini� class attached to enhanced element.", function(){
var full = document.getElementById("radio-full"),
$fulllbl = $('[for="radio-full"]'),
mini = document.getElementById("radio-mini"),
@@ -249,18 +249,30 @@
}
});
test( "nested label checkbox still renders", function() {
var $checkbox = $( "#checkbox-nested-label" );
try {
$checkbox.checkboxradio();
} catch (e) {
ok( false, "checkboxradio exception raised: " + e.toString());
}
ok( $checkbox.parent().hasClass("ui-checkbox"), "enhancement has occured");
});
test( "nested label checkbox still renders", function() {
var $checkbox = $( "#checkbox-nested-label" );
try {
$checkbox.checkboxradio();
} catch (e) {
ok( false, "checkboxradio exception raised: " + e.toString());
}
ok( $checkbox.parent().hasClass("ui-checkbox"), "enhancement has occured");
});
test( "nested label (no [for]) checkbox still renders", function() {
var $checkbox = $( "#checkbox-nested-label-no-for" );
try {
$checkbox.checkboxradio();
} catch (e) {
ok( false, "checkboxradio exception raised: " + e.toString());
}
ok( $checkbox.parent().hasClass("ui-checkbox"), "enhancement has occured");
});
test( "Icon positioning", function() {
var bottomicon = $("[for='bottomicon']")
topicon = $("[for='topicon']");
@@ -190,5 +190,13 @@ <h2 id="qunit-userAgent"></h2>
</label>
</form>
</div>
<div id="nested-label-no-for-test">
<form>
<label>
<input type="checkbox" name="checkbox-nested-label-no-for" id="checkbox-nested-label-no-for" class="custom"/>
</label>
</form>
</div>
</body>
</html>

0 comments on commit cf21c53

Please sign in to comment.