Skip to main content

Bug Tracker

Side navigation

#14435 closed feature (notabug)

Opened October 10, 2013 07:20AM UTC

Closed October 13, 2013 12:14PM UTC

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));
Attachments (0)
Change History (1)

Changed October 13, 2013 12:14PM UTC by dmethvin comment:1

resolution: → notabug
status: newclosed

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.