fiona0914 / simile-widgets

Automatically exported from code.google.com/p/simile-widgets
0 stars 0 forks source link

AJAX: Date parsing in version 2.2.2 cannot cope with 'null' values breaking Timeline (TypeError: Cannot read property 'toUTCString' of null "XmlHttp: Error handling onReadyStateChange") #416

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
The Ajax library doesn't support 'null' date values any more which breaks 
Timelines which have events
without an "end" attribute (i.e. the most of them!). This can be demonstrated 
by the "monet" example.

What steps will reproduce the problem?

1. svn co 
http://simile-widgets.googlecode.com/svn/ajax/tags/2.2.2/src/webapp/api ajax
2. svn co 
http://simile-widgets.googlecode.com/svn/timeline/tags/2.3.1/src/webapp/api 
timeline
3. svn co 
http://simile-widgets.googlecode.com/svn/timeline/trunk/src/webapp/examples/mone
t examples/monet
4. svn export 
http://simile-widgets.googlecode.com/svn/timeline/trunk/src/webapp/examples/styl
es.css examples/styles.css
5. svn export 
http://simile-widgets.googlecode.com/svn/timeline/trunk/src/webapp/styles.css
6. Change "examples/monet/monet.html" to have the following lines:
    <script src="../../ajax/simile-ajax-api.js?bundle=false" type="text/javascript"></script>
    <script src="../../timeline/timeline-api.js?bundle=false" type="text/javascript"></script>

What is the expected output?

  See events in the timeline.

What do you see instead?
  The timeline is empty and JavaScript console tells:

    TypeError: Cannot read property 'toUTCString' of null "XmlHttp: Error handling onReadyStateChange"

What version of the product are you using? On what browser and what operating 
system?

  Firefox 3.6/Chrome 8.0
  Windows XP

Please provide any additional information below.

The date parsing was broken by commits r1981 and r1984 to ajax\scripts\units.js 
(see 
http://code.google.com/p/simile-widgets/source/browse/ajax/trunk/src/webapp/api/
scripts/units.js?r=1984#25).

If variable "d" is "null", "typeof d != 'undefined'" is true (because "typeof 
null" is "object") and so the code tries to execute the toUTCString() method of 
a null object.

You can easily see that these commits are the problem by issuing:
  svn co -r1980 http://simile-widgets.googlecode.com/svn/ajax/trunk/src/webapp/api ajax

After this the timeline is displayed correctly. If you then do:
  >svn up -r1985 ajax
  U    ajax\simile-ajax-bundle.js
  U    ajax\scripts\units.js
  Updated to revision 1985.

Only units.js is updated and timeline is broken again.

You can fix the issue with the following change:

<        if (typeof d != 'undefined' && typeof d.toUTCString == "function") {
>        if (d != null && typeof d.toUTCString == "function") {

This works, because undefined and null values compare as equal.

Original issue reported on code.google.com by risto.ka...@gmail.com on 12 Dec 2010 at 2:33

GoogleCodeExporter commented 9 years ago

Original comment by ryan...@csail.mit.edu on 23 Jun 2011 at 9:49