]> source.dussan.org Git - jquery.git/commitdiff
Fix #10863. Allow newlines in JSON data- attributes.
authorDave Methvin <dave.methvin@gmail.com>
Fri, 24 Aug 2012 02:19:06 +0000 (22:19 -0400)
committerDave Methvin <dave.methvin@gmail.com>
Fri, 24 Aug 2012 02:19:06 +0000 (22:19 -0400)
src/data.js
test/unit/data.js

index f51a3e520c6b78e83950be73a595108fc7b8fa42..e5c3df6986e64bb63b55299a43ee5d23a96f932b 100644 (file)
@@ -1,4 +1,4 @@
-var rbrace = /^(?:\{.*\}|\[.*\])$/,
+var rbrace = /(?:\{[\s\S]*\}|\[[\s\S]*\])$/,
        rmultiDash = /([A-Z])/g;
 
 jQuery.extend({
index 7f4ad6c36bb627f79e68d8d29c992edd248d389a..765aefcd2a664c9ab07086dd0d5a6d4642098959 100644 (file)
@@ -646,5 +646,12 @@ test( "Only check element attributes once when calling .data() - #8909", functio
 
        // clean up data cache
        element.remove();
-
 });
+
+test( "JSON data- attributes can have newlines", function() {
+       expect(1);
+       
+       var x = jQuery("<div data-some='{\n\"foo\":\n\t\"bar\"\n}'></div>");
+       equal( x.data("some").foo, "bar", "got a JSON data- attribute with spaces" );
+       x.remove();
+});
\ No newline at end of file