From 2263134b224fe03b90552369b5007220747fbaf0 Mon Sep 17 00:00:00 2001 From: Dave Methvin Date: Thu, 23 Aug 2012 22:19:06 -0400 Subject: [PATCH] Fix #10863. Allow newlines in JSON data- attributes. --- src/data.js | 2 +- test/unit/data.js | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/data.js b/src/data.js index f51a3e520c..e5c3df6986 100644 --- a/src/data.js +++ b/src/data.js @@ -1,4 +1,4 @@ -var rbrace = /^(?:\{.*\}|\[.*\])$/, +var rbrace = /(?:\{[\s\S]*\}|\[[\s\S]*\])$/, rmultiDash = /([A-Z])/g; jQuery.extend({ diff --git a/test/unit/data.js b/test/unit/data.js index 7f4ad6c36b..765aefcd2a 100644 --- a/test/unit/data.js +++ b/test/unit/data.js @@ -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("
"); + equal( x.data("some").foo, "bar", "got a JSON data- attribute with spaces" ); + x.remove(); +}); \ No newline at end of file