From f82b9dddc498efdfbcd0978f8ba3e1da3b48eff3 Mon Sep 17 00:00:00 2001 From: rwldrn Date: Fri, 20 May 2011 11:03:33 -0400 Subject: [PATCH] Landing pull request 382. Adds support for number values (meter,progress); Fixes #9319. More Details: - https://github.com/jquery/jquery/pull/382 - http://bugs.jquery.com/ticket/9319 --- src/attributes.js | 8 +++++++- test/unit/attributes.js | 24 ++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/src/attributes.js b/src/attributes.js index c239dd7f..5396a90e 100644 --- a/src/attributes.js +++ b/src/attributes.js @@ -165,7 +165,13 @@ jQuery.fn.extend({ return ret; } - return (elem.value || "").replace(rreturn, ""); + ret = elem.value; + + return typeof ret === "string" ? + // handle most common string cases + ret.replace(rreturn, "") : + // handle cases where value is null/undef or number + ret == null ? "" : ret; } return undefined; diff --git a/test/unit/attributes.js b/test/unit/attributes.js index c4ed7d30..56c398e5 100644 --- a/test/unit/attributes.js +++ b/test/unit/attributes.js @@ -611,6 +611,30 @@ test("val()", function() { equals( jQuery("