From c57728a8d90b64e31d602cc4cf90f845a13bed32 Mon Sep 17 00:00:00 2001 From: Andreas Piening Date: Tue, 3 Aug 2010 02:06:40 +0000 Subject: [PATCH] ENHANCEMENT Only defining document.getElementsByClassName() in prototype.js if no native implementation exists (which speeds up the CMS). Ported from 'jquery13' module, thanks Hamish (from r100849) git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@108813 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- thirdparty/prototype/prototype.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/thirdparty/prototype/prototype.js b/thirdparty/prototype/prototype.js index f836262d7..919834b41 100644 --- a/thirdparty/prototype/prototype.js +++ b/thirdparty/prototype/prototype.js @@ -1006,13 +1006,16 @@ Ajax.Evaluator = function(response) { } -document.getElementsByClassName = function(className, parentElement) { - var children = ($(parentElement) || document.body).getElementsByTagName('*'); - return $A(children).inject([], function(elements, child) { - if (child.className.match(new RegExp("(^|\\s)" + className + "(\\s|$)"))) - elements.push(child); - return elements; - }); +// Only define this if no native (and significantly faster) implementation exists. +if(!document.getElementsByClassName) { + document.getElementsByClassName = function(className, parentElement) { + var children = ($(parentElement) || document.body).getElementsByTagName('*'); + return $A(children).inject([], function(elements, child) { + if (child.className.match(new RegExp("(^|\\s)" + className + "(\\s|$)"))) + elements.push(child); + return elements; + }); + } } /*--------------------------------------------------------------------------*/