Opened 9 years ago
Closed 9 years ago
#14435 closed feature (notabug)
Serializing the value of text() from empty DOM element in IE8 result "null" string
Reported by: | randing89 | Owned by: | |
---|---|---|---|
Priority: | undecided | Milestone: | None |
Component: | unfiled | Version: | 1.10.2 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
This is a known issue in IE8 which described here: http://blogs.msdn.com/b/jscript/archive/2009/06/23/serializing-the-value-of-empty-dom-elements-using-native-json-in-ie8.aspx
When trying to use JSON.stringify() to serialize the value of an empty DOM element. It returns "null" instead of "". It would be better if JQuery can handle this issue.
Test code:
<div></div>
$('div').text(''); var t = $('div').text(); $('body').append(t); $('body').append(JSON.stringify(t));
Note: See
TracTickets for help on using
tickets.
jQuery doesn't provide any shim for stringifying to a JSON object so this is out of scope. As a workaround in your code, just include json2.js and use it instead of the native
window.JSON
object.