Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #4477: prototype-perf-patch-i3.diff

File prototype-perf-patch-i3.diff, 1.5 kB (added by Thomas Fuchs <t.fuchs@wollzelle.com>, 4 years ago)

Fixes problems on Safari

  • prototype.js

    old new  
    900900 
    901901Element.extend = function(element) { 
    902902  if (!element) return; 
     903  if (_nativeExtensions) return element; 
    903904 
    904905  if (!element._extended && element.tagName && element != window) { 
    905906    var methods = Element.Methods, cache = Element.extend.cache; 
     
    11131114 
    11141115Object.extend(Element, Element.Methods); 
    11151116 
     1117var _nativeExtensions = false; 
     1118 
     1119if(!HTMLElement && /Konqueror|Safari|KHTML/.test(navigator.userAgent)) { 
     1120  var HTMLElement = {} 
     1121  HTMLElement.prototype = document.createElement('div').__proto__; 
     1122} 
     1123 
     1124if(typeof HTMLElement != 'undefined') { 
     1125  var methods = Element.Methods, cache = Element.extend.cache; 
     1126  for (property in methods) { 
     1127    var value = methods[property]; 
     1128    if (typeof value == 'function') 
     1129      HTMLElement.prototype[property] = cache.findOrStore(value); 
     1130  } 
     1131  _nativeExtensions = true; 
     1132} 
     1133 
     1134Element.addMethods = function(methods) { 
     1135  Object.extend(Element.Methods, methods); 
     1136   
     1137  if(_nativeExtensions) { 
     1138    var tmp = document.createElement('div'); 
     1139    var methods = Element.Methods, cache = Element.extend.cache; 
     1140    for (property in methods) { 
     1141      var value = methods[property]; 
     1142      if (typeof value == 'function') 
     1143        HTMLElement.prototype[property] = cache.findOrStore(value); 
     1144    } 
     1145  } 
     1146} 
     1147 
    11161148var Toggle = new Object(); 
    11171149Toggle.display = Element.toggle; 
    11181150