View Full Version : unterminated string literal error in yui-ext.js 0.32.2?

6 Oct 2006, 4:27 AM
Just upgraded to 0.32.2 and got the following error (WinXP FF

unterminated string literal
yui-ext.js (line 85)
this.compiled = function(values){ return '<span class="ygrid-hd ygrid-header-' + values[0] + '" toJSONString="function () {

This happens on page load. I haven't seen anyone else report it, so maybe it's just me, but just in case...


6 Oct 2006, 5:03 AM
Hi kschneid,

Is it possible you can put up a page with the error? I downloaded the zip from the server and can't seem to get the error.

BTW, do you have toJSONString() defined somewhere? I pretty sure that function isn't in yui-ext and I'm wondering how it ended up in the middle of grid header building code. :)


6 Oct 2006, 5:40 AM
Can't put up a page at the moment, but I'll look a little closer at my env. I was using 0.32.1 w/o a problem and merely copied the new yui-ext.js.

As for toJSONString, I'm also using json.js (http://www.json.org/js.html) which adds toJSONString to the prototypes of both Object and Array. Again, not sure why that's all of a sudden an issue, but I'll poke around a bit...


6 Oct 2006, 6:27 AM
The headers in the grid are built by enumerating attributes in an object literal (new in this version, provided by DomHelper). The json site you pointed me to is extending the Object prototype.

Extending the Object prototype is generally frowned upon because it breaks for ... in statements. Object literals end up with functions and enumerating them requires you to check every entry to see if it's a function. Most of the code I develop assumes people follow this unofficial "standard".

I will include a check in the next maintence release to filter functions but there could be other spots in yui-ext affected by this.

On a side note, to avoid possible conflicts with not only yui-ext but other libraries you might include as well, I would recommend (if it's an option) to remove that function from the Object prototype. The difference between calling, say, JSON.encode(obj) and obj.toJSONString() is minimal. Actually I just counted and it's 2 characters shorter. ;)