
david at kineticode
Mar 18, 2010, 10:38 PM
Post #2 of 8
(1437 views)
Permalink
|
|
Re: Prototype 1.6.0.3 and getElementsByClassName
[In reply to]
|
|
On Mar 18, 2010, at 5:11 PM, Adrian Yee wrote: > Hi, > > Bricolage 2.x uses Prototype 1.6.0.3 and in various bits of Bricolage's JavaScript, it uses getElementsByClassName(). The problem is that newer browsers have a native implementation of it which is different to what Prototype implements, causing slight differences in what it returns. See: > > http://www.prototypejs.org/api/element/getElementsByClassName > > For example, we have this snippet of code in comp/media/js/lib.js, FastAdd.add(): > > document.getElementsByClassName('value', this.list) > > which I believe is supposed to return an array of elements in this.list that have the 'value' class. Because Prototype doesn't declare its version of the function on modern browsers that already have that function, it returns all elements in the _whole document_ with the value class. > > I'd create a patch for this, but I'm not 100% on Bricolage's UI to test the changes. There aren't too many uses of getElementsByClassName(), but I believe things like: > > lbActions = document.getElementsByClassName('lbAction'); > > should get changed to: > > lbActions = $$('.lbAction'); That one seems to be gone already. > > and: > > document.getElementsByClassName('value', this.list) > > to: > > this.list.select('.value') So does the attached patch look right? I ran Bricolage and I *think* I tested the functions that were changed by playing with the corresponding UI. I'd appreciate confirmation from others. Best, David
|