When I use the patagonia site, I get a bunch of dialog windows with javascript errors. I do not get any errors with Safari and Firefox. Here is the first message: Something is erroring: File Name: TopNav.js Function Name: InitializeTopNav Message: TypeError: Value undefined (result of expression M_arrTopMenu.each) is not object., undefined Refreshing your browser window may fix things.
I came across this as well, it looks like it works in Safari Version 2.0.4 (419.3) so maybe we can get this marked as a regression.
The initial page (http://www.patagonia.com) has a parse error in the JavaScript console from the Prototype library using a local debug build of WebKit r20722 with Safari 2.0.4 (419.3) on Mac OS X 10.4.9 (8P135): SyntaxError: Parse error http://www.patagonia.com/usa/js/prototype.js Line: 1807 The top of the prototype.js file says: /* Prototype JavaScript framework, version 1.4.0 * (c) 2005 Sam Stephenson <sam@conio.net> My guess is that the site needs to update their version of the library (which is 1.5.0 as of this writing). The code that's borken (which may or may not be a legitimate bug): var Cookie = { set: function(name, value, daysToExpire) { var expire = ''; if (daysToExpire != undefined) { var d = new Date(); d.setTime(d.getTime() + (86400000 * parseFloat(daysToExpire))); expire = '; expires=' + d.toGMTString(); } return (document.cookie = escape(name) + '=' + escape(value || '') + expire); }, get: function(name) { var cookie = document.cookie.match(new RegExp('(^|;)\\s*' + escape(name) + '=([^;\\s]*)')); return (cookie ? unescape(cookie[2]) : null); }, erase: function(name) { var cookie = Cookie.get(name) || true; Cookie.set(name, '', -1); return cookie; }, accept: function() { if (typeof (navigator.cookieEnabled) == 'boolean') { return navigator.cookieEnabled; } Cookie.set('_test', '1'); return (Cookie.erase('_test') = '1'); // Line 1807 } };
(In reply to comment #2) > The code that's borken (which may or may not be a legitimate bug): This is a legitimate bug at first glance. The code in question parses fine with Safari 2.0.4 (419.3) on Mac OS X 10.4.9 (8P135) but does not with a local debug build of WebKit r20722. Attaching semi-reduced test case next.
Created attachment 13970 [details] Test case (partially reduced) This is a partially reduced (read: copied-and-pasted) test case. It could probably be reduced further. Parses fine with Safari 2.0.4 (419.3) on Mac OS X 10.4.9 (8P135), but not with WebKit r20722 thrown into the mix.
(In reply to comment #2) > The code that's borken (which may or may not be a legitimate bug): > [...] > return (Cookie.erase('_test') = '1'); // Line 1807 Or maybe this a parse error? Shouldn't "=" be "==" here?
(In reply to comment #5) > (In reply to comment #2) > > The code that's borken (which may or may not be a legitimate bug): > > [...] > > return (Cookie.erase('_test') = '1'); // Line 1807 > > Or maybe this a parse error? Shouldn't "=" be "==" here? Changing "=" to "==" fixed the parsing issue. Oddly, Firefox 2.0.0.3 allows this statement, although I'm not sure what it's doing (setting the value of an object to '1'?). I don't have any way to test MSIE 6/7 with this. Leaving this as a P1 REGRESSION until further analysis can be performed by someone more knowledgeable. This could easily be an evangelism bug as well.
The code below is NOT a part of Prototype.js 1.4.0. Apparently it has been added by the site's author, which makes it more likely an evangelism bug. http://dev.conio.net/repos/prototype/pkg/prototype-1.4.0.tar.gz (In reply to comment #2) > The code that's borken (which may or may not be a legitimate bug): > > var Cookie = { > set: function(name, value, daysToExpire) { > var expire = ''; > if (daysToExpire != undefined) { > var d = new Date(); > d.setTime(d.getTime() + (86400000 * parseFloat(daysToExpire))); > expire = '; expires=' + d.toGMTString(); > } > return (document.cookie = escape(name) + '=' + escape(value || '') + > expire); > }, > get: function(name) { > var cookie = document.cookie.match(new RegExp('(^|;)\\s*' + escape(name) + > '=([^;\\s]*)')); > return (cookie ? unescape(cookie[2]) : null); > }, > erase: function(name) { > var cookie = Cookie.get(name) || true; > Cookie.set(name, '', -1); > return cookie; > }, > accept: function() { > if (typeof (navigator.cookieEnabled) == 'boolean') { > return navigator.cookieEnabled; > } > Cookie.set('_test', '1'); > return (Cookie.erase('_test') = '1'); // Line 1807 > } > };
Thanks everyone for looking into this. You're correct, we're running version 1.4 of prototype.js library but the cookie section of it is an "add on". When looking at this line: return (Cookie.erase('_test') = '1'); // Line 1807 I agree, it looks like it should be returning a bool, and as such, it looks like it should be a "==" and not "=". I'll check it out today.
I have updated this code on patagonia.com.
(In reply to comment #9) > I have updated this code on patagonia.com. Thanks! Patricia, could you test the site again to see if you still are getting any errors? Thanks!
(In reply to comment #10) > Patricia, could you test the site again to see if you still are getting any > errors? Thanks! It looks like the changes haven't been pushed out to the live site quite yet. Please wait a day or two(?) until the change has been deployed.
The change is definitely out there: http://www.patagonia.com/web/us/js/prototype.js Try clearing your cache.
This was the function I updated, note the last line: accept: function() { if (typeof (navigator.cookieEnabled) == 'boolean') { return navigator.cookieEnabled; } Cookie.set('_test', '1'); return (Cookie.erase('_test') == '1'); } While debugging this I discovered that the bug never surfaced for us because all of our supported browsers offer the "cookieEnabled" property and, hence, never got down to the bottom of the function. I commented out the 'cookieEnabled' portion of the code to force Firefox to the bottom and was able to reproduce the error you all reported. It now properly returns a bool.
I'm not sure whether the fix is in the version I am using (20766) but I got an error the first time I clicked on the Go button after selecting USA as the country. But when I repeated it the error did not occur. Here is the message (the dialog box did not appear on top of the window ... I only found it by accident) Something is erroring: File Name: Global.js Function Name: DisplayPopUp Message: TypeError: Value undefined (result of expression Element.setStyle) is not object., undefined Refreshing your browser window may fix things.
(In reply to comment #12) > The change is definitely out there: > > http://www.patagonia.com/web/us/js/prototype.js > > Try clearing your cache. That file has been corrected. This file has not (note different URL)! http://www.patagonia.com/usa/js/prototype.js This is referenced from this page (which is the one I get when I access http://www.patagonia.com/ directly): http://www.patagonia.com/web/us/intern_landing.jsp?OPTION=SAR&assetid=15546&target=%2Fhome%2Findex.jsp%3FOPTION%3DHOME_PAGE%26assetid%3D1704
Interesting - you will only see that 'usa' directory if you are configured to block all cookies. I made the fix so that the 'usa' directory now sees the corrected version of the prototype js library. Thanks.
(In reply to comment #16) > Interesting - you will only see that 'usa' directory if you are configured to > block all cookies. I made the fix so that the 'usa' directory now sees the > corrected version of the prototype js library. Thanks. > So it means the bug is already fixed. I checked the page using Webkit r30218 with Cookie enabled and again with disabled. The site works without error.