From 5c6c99361f315bfbc5829be3af94499c3a107f5d Mon Sep 17 00:00:00 2001 From: David Serduke Date: Wed, 28 Nov 2007 16:38:34 +0000 Subject: [PATCH] Fixed #1714 by adding a default empty string if the value is falsey. --- src/core.js | 2 +- test/unit/core.js | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/core.js b/src/core.js index ce265196..0ebc61df 100644 --- a/src/core.js +++ b/src/core.js @@ -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, ""); } diff --git a/test/unit/core.js b/test/unit/core.js index cea8c61e..e71de2db 100644 --- a/test/unit/core.js +++ b/test/unit/core.js @@ -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() {