safari 3.1 breaks your app
Courtenay : March 21st, 2008
If you're doing anything like
$('foo').getElementsByClassName("monkey").each(Element.hide)
Safari 3.1 out this week breaks this, because it now natively implements getElementsByClassName.
So, pending a fix from the Prototype guys, one of whom has a desk next to mine, be aware that your apps may be broken for your Safari users.
You can easily change that code to
$$("#foo .monkey").each(Element.hide)
9 Responses to “safari 3.1 breaks your app”
Sorry, comments are closed for this article.
March 21st, 2008 at 01:37 PM
Thank you for the heads up!
March 21st, 2008 at 04:23 PM
The most elegant would be probably: $$('#foo .monkey').invoke('hide')
March 22nd, 2008 at 04:28 PM
Yep. Mine's broke. Noticed some drag&drop not working in one of my client's apps. From a casual glance at prototype.js it looks like it's trying to handle browsers that support the method natively. On line 2164 of 1.6.0_rc0 I see a test for presence of the native method on document. Well, that's what I get for "casually" glancing at prototype.
March 23rd, 2008 at 12:14 AM
The $$ selector function is great but it doesn't replace getElementsByClassName's optional parentElement parameter - which I use all the time. Or does it?
I saw in Prototype that getElementsByClassName is marked as deprecated. It seems like I must be missing something..
Thanks for the heads up though. I was certainly wondering what was going on.
March 23rd, 2008 at 12:14 AM
The $$ selector function is great but it doesn't replace getElementsByClassName's optional parentElement parameter - which I use all the time. Or does it?
I saw in Prototype that getElementsByClassName is marked as deprecated. It seems like I must be missing something..
Thanks for the heads up though. I was certainly wondering what was going on.
March 24th, 2008 at 01:39 PM
Thanks! - I switched to using $$ and it fixed it right up for me.
March 24th, 2008 at 03:05 PM
This'll do what you want.
http://prototypejs.org/api/element/select
March 25th, 2008 at 07:01 AM
Thanks, this is exactly where I was stuck at: debugging active_scaffold.js in the exact line of getElementsByClassName where ir registers the close handler for the cancel links.
This bug shows up at Firefox 3 as well, it seems. If you use Active Scaffold, take a look at this thread for a solution: http://groups.google.com/group/activescaffold/browse_thread/thread/d37afa3f2ac687f2
March 25th, 2008 at 10:40 AM
yep, .select did it.
For the record, I changed:
elms = document.getElementsByClassName('classname',parentElement);
into
elms = $(parentElement).select('.classname');
The $ is handy when the element isn't yet extended OR is an id and don't forget to put the '.' in front of the class name to make it a class selector.
Thanks for your help. (PS, any CSS you can add to the "Submit Comment" button on this page that would give click feedback would be a good idea... sorry for the double post earlier)