From 7ef40fd19926c779086ae7d79796032708d568e0 Mon Sep 17 00:00:00 2001 From: David Serduke Date: Tue, 18 Dec 2007 17:19:33 +0000 Subject: [PATCH] Fixed #2076 where .val() could return an array instead of undefined when the jquery object was empty. The bug was created during the .val() refactoring for the javascript strict FF ticket. --- src/core.js | 1 + test/unit/core.js | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/core.js b/src/core.js index 4decf3e..ad938f2 100644 --- a/src/core.js +++ b/src/core.js @@ -419,6 +419,7 @@ jQuery.fn = jQuery.prototype = { } + return undefined; } return this.each(function(){ diff --git a/test/unit/core.js b/test/unit/core.js index 30fff77..932d0a5 100644 --- a/test/unit/core.js +++ b/test/unit/core.js @@ -1029,11 +1029,12 @@ test("$.extend(Object, Object)", function() { }); test("val()", function() { - expect(3); + expect(4); 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" ); + ok( $([]).val() === undefined, "Check an empty jQuery object will return undefined from val" ); }); test("val(String)", function() { -- 1.7.10.4