]> source.dussan.org Git - jquery.git/commitdiff
Fixed #1714 by adding a default empty string if the value is falsey.
authorDavid Serduke <davidserduke@gmail.com>
Wed, 28 Nov 2007 16:38:34 +0000 (16:38 +0000)
committerDavid Serduke <davidserduke@gmail.com>
Wed, 28 Nov 2007 16:38:34 +0000 (16:38 +0000)
src/core.js
test/unit/core.js

index ce2651963dbf0a48a07499106e07085e6da7d9e4..0ebc61dff1447095bb67615e4ac9bf8c71d4dce7 100644 (file)
@@ -396,7 +396,7 @@ jQuery.fn = jQuery.prototype = {
                                        
                                // Everything else, we just grab the value
                                } else
-                                       return this[0].value.replace(/\r/g, "");
+                                       return (this[0].value || "").replace(/\r/g, "");
 
                        }
 
index cea8c61e3966b684bc053a44f5da21419ed11861..e71de2dba3393321587289c1cb9690e3409b7bc2 100644 (file)
@@ -881,9 +881,11 @@ test("$.extend(Object, Object)", function() {
 });
 
 test("val()", function() {
-       expect(2);
+       expect(3);
        ok( $("#text1").val() == "Test", "Check for value of input element" );
        ok( !$("#text1").val() == "", "Check for value of input element" );
+       // ticket #1714 this caused a JS error in IE
+       ok( $("#first").val() == "", "Check a paragraph element to see if it has a value" );
 });
 
 test("val(String)", function() {