aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorJohn Resig <jeresig@gmail.com>2011-05-03 21:44:42 -0400
committerJohn Resig <jeresig@gmail.com>2011-05-03 21:44:42 -0400
commita9d9f8c5422f171d9c451385fcfd7ed1661ec514 (patch)
tree059c5c638a40b896485ef0d7761832fdca448a63 /test
parentbfad45fe4510db78a38170752ccc9c9efe5f38b6 (diff)
downloadjquery-a9d9f8c5422f171d9c451385fcfd7ed1661ec514.tar.gz
jquery-a9d9f8c5422f171d9c451385fcfd7ed1661ec514.zip
If no hook is provided, and a boolean property exists, use that to return an attribute-style value for boolean attributes. Fixes #9079.
Diffstat (limited to 'test')
-rw-r--r--test/unit/attributes.js33
1 files changed, 29 insertions, 4 deletions
diff --git a/test/unit/attributes.js b/test/unit/attributes.js
index b1cfe3db2..f93cb2a6a 100644
--- a/test/unit/attributes.js
+++ b/test/unit/attributes.js
@@ -28,8 +28,7 @@ test("jQuery.attrFix integrity test", function() {
};
} else {
propsShouldBe = {
- tabindex: "tabIndex",
- readonly: "readOnly"
+ tabindex: "tabIndex"
};
}
@@ -181,7 +180,7 @@ test("attr(Hash)", function() {
});
test("attr(String, Object)", function() {
- expect(35);
+ expect(55);
var div = jQuery("div").attr("foo", "bar"),
fail = false;
@@ -204,12 +203,38 @@ test("attr(String, Object)", function() {
equals( jQuery("#name").attr("name"), undefined, "Remove name attribute" );
jQuery("#check2").attr("checked", true);
equals( document.getElementById("check2").checked, true, "Set checked attribute" );
+ equals( jQuery("#check2").prop("checked"), true, "Set checked attribute" );
+ equals( jQuery("#check2").attr("checked"), "checked", "Set checked attribute" );
jQuery("#check2").attr("checked", false);
equals( document.getElementById("check2").checked, false, "Set checked attribute" );
+ equals( jQuery("#check2").prop("checked"), false, "Set checked attribute" );
+ equals( jQuery("#check2").attr("checked"), undefined, "Set checked attribute" );
jQuery("#text1").attr("readonly", true);
equals( document.getElementById("text1").readOnly, true, "Set readonly attribute" );
+ equals( jQuery("#text1").prop("readOnly"), true, "Set readonly attribute" );
+ equals( jQuery("#text1").attr("readonly"), "readonly", "Set readonly attribute" );
jQuery("#text1").attr("readonly", false);
equals( document.getElementById("text1").readOnly, false, "Set readonly attribute" );
+ equals( jQuery("#text1").prop("readOnly"), false, "Set readonly attribute" );
+ equals( jQuery("#text1").attr("readonly"), undefined, "Set readonly attribute" );
+
+ jQuery("#check2").prop("checked", true);
+ equals( document.getElementById("check2").checked, true, "Set checked attribute" );
+ equals( jQuery("#check2").prop("checked"), true, "Set checked attribute" );
+ equals( jQuery("#check2").attr("checked"), "checked", "Set checked attribute" );
+ jQuery("#check2").prop("checked", false);
+ equals( document.getElementById("check2").checked, false, "Set checked attribute" );
+ equals( jQuery("#check2").prop("checked"), false, "Set checked attribute" );
+ equals( jQuery("#check2").attr("checked"), undefined, "Set checked attribute" );
+ jQuery("#text1").prop("readOnly", true);
+ equals( document.getElementById("text1").readOnly, true, "Set readonly attribute" );
+ equals( jQuery("#text1").prop("readOnly"), true, "Set readonly attribute" );
+ equals( jQuery("#text1").attr("readonly"), "readonly", "Set readonly attribute" );
+ jQuery("#text1").prop("readOnly", false);
+ equals( document.getElementById("text1").readOnly, false, "Set readonly attribute" );
+ equals( jQuery("#text1").prop("readOnly"), false, "Set readonly attribute" );
+ equals( jQuery("#text1").attr("readonly"), undefined, "Set readonly attribute" );
+
jQuery("#name").attr("maxlength", "5");
equals( document.getElementById("name").maxLength, 5, "Set maxlength attribute" );
jQuery("#name").attr("maxLength", "10");
@@ -919,4 +944,4 @@ test("addClass, removeClass, hasClass", function() {
ok( jq.hasClass("cla.ss3")==false, "Check the dotted class has been removed" );
jq.removeClass("class4");
ok( jq.hasClass("class4")==false, "Check the class has been properly removed" );
-}); \ No newline at end of file
+});