Permalink
Browse files

Made getElementsByClassName actually work

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@991 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent 4513779 commit 771244a58ce812198e7171e4ee0ae5b27032ead0 @dhh dhh committed Mar 25, 2005
Showing with 24 additions and 13 deletions.
  1. +24 −13 actionpack/lib/action_view/helpers/javascripts/prototype.js
@@ -86,23 +86,34 @@ function $() {
}
function getElementsByClassName(className, element) {
- var children = (element || document).getElementsByTagName('*');
+ var all = document.all ? document.all : document.getElementsByTagName(element);
var elements = new Array();
-
- for (var i = 0; i < children.length; i++) {
- var child = children[i];
- var classNames = child.className.split(' ');
- for (var j = 0; j < classNames.length; j++) {
- if (classNames[j] == className) {
- elements.push(child);
- break;
- }
- }
- }
-
+
+ for (var e = 0; e < all.length; e++)
+ if (all[e].className == className)
+ elements[elements.length] = all[e];
+
return elements;
}
+// function getElementsByClassName(className, element) {
+// var children = (element || document).getElementsByTagName('*');
+// var elements = new Array();
+//
+// for (var i = 0; i < children.length; i++) {
+// var child = children[i];
+// var classNames = child.className.split(' ');
+// for (var j = 0; j < classNames.length; j++) {
+// if (classNames[j] == className) {
+// elements.push(child);
+// break;
+// }
+// }
+// }
+//
+// return elements;
+// }
+
/*--------------------------------------------------------------------------*/
Ajax = {

0 comments on commit 771244a

Please sign in to comment.