Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
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...
commit 771244a58ce812198e7171e4ee0ae5b27032ead0 1 parent 4513779
David Heinemeier Hansson dhh authored
Showing with 24 additions and 13 deletions.
  1. +24 −13 actionpack/lib/action_view/helpers/javascripts/prototype.js
37 actionpack/lib/action_view/helpers/javascripts/prototype.js
View
@@ -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 = {
Please sign in to comment.
Something went wrong with that request. Please try again.