Export to GitHub

json-template - issue #5

Live example doesn't work in IE6


Posted on Mar 31, 2009 by Grumpy Bird

What steps will reproduce the problem? 1. Run jslint on json-template.js

What is the expected output? What do you see instead?

Lint at line 376 character 25: Extra comma. 'space': ' ',

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

Windows IE6

Please provide any additional information below.

You mentioned in the demo that it doesn't work in IE6 so I thought I would check it out.

First it didn't work but didn't give any debugger info, so I ran the script through jslint, and it found an extra comma at the end of one of your objects:

Lint at line 376 character 25: Extra comma. 'space': ' ',

Then after removing that comma, it was giving me a debugger error, but I haven't quite figured that out. Attaching debugger screenshot for your info.

Attachments

Comment #1

Posted on Mar 31, 2009 by Quick Hippo

Thanks, I just fixed all the jslint errors.

And that stack trace looks interesting... I guess there is some difference in IE behavior. I will have to look at that later tonight.

Basically that exception is thrown when there's an undefined template variable during expansion. But none of the other browsers see it as undefined.

http://json-template.googlecode.com/svn/trunk/doc/testTableExample-001.js.html

Comment #2

Posted on Apr 6, 2009 by Quick Bear

The major reason IE6 is not working is that the String.prototype.split method does not return captured groups in the result. For reference see http://blog.stevenlevithan.com/archives/cross-browser-split.

The other reason is that IE6 does not let you index strings as an array, so "token[0]" needs to be replaced with "token.charAt(0)" in function "_Compile".

These two changes make it work in IE6

Comment #3

Posted on Apr 6, 2009 by Helpful Rhino

Great thanks. I'm not sure if it's better to include that fix or just write a loop by hand to tokenize it... the regex is pretty simple, so maybe we can get rid of it.

I will look at it this week (patches are welcome too).

Comment #4

Posted on Apr 6, 2009 by Quick Bear

Didn't have time to look into it further, just thought i'd let you know where the problem arises.

I think if you'd do a "match" instead of a "split" it is basically fixed...

I will see if i have some time to look into it..

Comment #5

Posted on Apr 20, 2009 by Quick Hippo

Thanks, your suggestions were spot on.

Status: Fixed

Labels:
Type-Defect Priority-Medium