diff options
author | Dave Methvin <dave.methvin@gmail.com> | 2012-08-23 22:19:06 -0400 |
---|---|---|
committer | Dave Methvin <dave.methvin@gmail.com> | 2012-08-23 22:19:06 -0400 |
commit | 2263134b224fe03b90552369b5007220747fbaf0 (patch) | |
tree | 19eafba46df27bccadd3541e8a300cbd91a97325 | |
parent | c01e022f33575ed45fb8da65be756fc464d40a24 (diff) | |
download | jquery-2263134b224fe03b90552369b5007220747fbaf0.tar.gz jquery-2263134b224fe03b90552369b5007220747fbaf0.zip |
Fix #10863. Allow newlines in JSON data- attributes.
-rw-r--r-- | src/data.js | 2 | ||||
-rw-r--r-- | test/unit/data.js | 9 |
2 files changed, 9 insertions, 2 deletions
diff --git a/src/data.js b/src/data.js index f51a3e520..e5c3df698 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 7f4ad6c36..765aefcd2 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("<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 |