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("
"); + equal( x.data("some").foo, "bar", "got a JSON data- attribute with spaces" ); + x.remove(); +}); \ No newline at end of file