Opened 8 years ago

Closed 8 years ago

#17666 closed defect (worksforme)

json.stringify generates "null" value for strings which have "" value in IE8

Reported by: drcoelho Owned by:
Priority: undecided Milestone: tbd
Component: Dijit - Form Version: 1.9.2
Keywords: Cc:
Blocked By: Blocking:

Description (last modified by ben hockey)

Given a javascript object (returned from a dijit/Form) that contains one or more string values, each of which has an empty value, e.g. "" and each of which is typeof == "string", the stringify method is returning a value of "null".

This occurs only on IE8 (version 8.0.6001.18702).

This seems to be something peculiar to the objects returned by dijit/Form.

Oddly, the following kludge fixes the issue:

var form = registry.byId('my_form').get('value');
// at this point form['mystr'] has a value of ''
// and JSON.stringify(form) returns '{"mystr":"null"}'

// but if we do the following:
for (var key in form) {
  if ( (typeof form[key] == "string") && (form[key] == '') ) {
    form[key] = '';

// now it works!!!
// and JSON.stringify(form) returns '{"mystr":""}'

Change History (3)

comment:1 Changed 8 years ago by ben hockey

Description: modified (diff)

comment:2 Changed 8 years ago by freddefisk

I have also experienced this issue with Internet Explorer 8, but without using the dijit/Form. I think I got this weird empty string value when simply calling get("value") on a ValidationTextBox?.

Can you also reproduce this with a simple example without dijit/Form?

comment:3 Changed 8 years ago by bill

Resolution: worksforme
Status: newclosed

You didn't attach a test case so I tried dijit/tests/form/test_Form_state.html. It works fine for me:


My IE version is also 8.0.6001.18702, and I'm running on Windows XP.

Note: See TracTickets for help on using tickets.