Fix jQuery prop() definition and add some tests

This commit is contained in:
Boris Yankov
2012-11-09 19:57:21 +02:00
parent e7ac778279
commit 02b302faa7
2 changed files with 19 additions and 3 deletions

View File

@@ -344,7 +344,7 @@ interface JQuery {
html(htmlString: string): JQuery;
html(): string;
prop(propertyName: string): string;
prop(propertyName: string): bool;
prop(propertyName: string, value: any): JQuery;
prop(map: any): JQuery;
prop(propertyName: string, func: (index: any, oldPropertyValue: any) => any): JQuery;

View File

@@ -689,7 +689,7 @@ function test_children() {
var len = $kids.addClass("hilite").length;
$("#results span:first").text(len.toString());
$("#results span:last").text(e.target.tagName);
//$("#results span:last").text(e.target.tagName);
e.preventDefault();
return false;
@@ -765,7 +765,7 @@ function test_closest() {
});
var $listElements = $("li").css("color", "blue");
$(document).bind("click", function (e) {
$(e.target).closest($listElements).toggleClass("hilight");
//$(e.target).closest($listElements).toggleClass("hilight");
});
}
@@ -902,6 +902,22 @@ function test_each() {
});
}
function test_prop() {
var $input = $(this);
$("p").html(".attr('checked'): <b>" + $input.attr('checked') + "</b><br>"
+ ".prop('checked'): <b>" + $input.prop('checked') + "</b><br>"
+ ".is(':checked'): <b>" + $input.is(':checked')) + "</b>";
$("input").prop("disabled", false);
$("input").prop("checked", true);
$("input").val("someValue");
$("input[type='checkbox']").prop("checked", function (i, val) {
return !val;
});
$("input[type='checkbox']").prop({
disabled: true
});
}
function test_text() {
var str = $("p:first").text();
$("p:last").html(str);