Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

prototype.js won't load due it clobbering "Element"

#108

prototype.js has the following gem:

(function() {                                                                                                                                  
var element = this.Element;
this.Element = function(tagName, attributes) {


attributes = attributes || { };
tagName = tagName.toLowerCase();                                                                                                             
var cache = Element.cache;                                                                                                                   
if (Prototype.Browser.IE && attributes.name) {                                                                                               
  tagName = '<' + tagName + ' name="' + attributes.name + '">';                                                                              
  delete attributes.name;                                                                                                                    
  return Element.writeAttribute(document.createElement(tagName), attributes);                                                                
}                                                                                                                                            
if (!cache[tagName]) cache[tagName] = Element.extend(document.createElement(tagName));                                                       
return Element.writeAttribute(cache[tagName].cloneNode(false), attributes);



};
Object.extend(this.Element, element || { });
if (element) this.Element.prototype = element.prototype;
}).call(window);

This effectively wipes out envjs's Element. Here's the trace

nickg-macbook:env-js nickg$ ./tester.sh  
Rhino 1.7 release 2 2009 03 22
js> load("client9-env-js/dist/env.rhino.js");
[  Envjs/1.6 (Rhino; U; Mac OS X x86_64 10.6.2; en-US; rv:1.7.0.rc2) Resig/20070309 PilotFish/1.2.0.6  ]
js> load('/Users/nickg/Downloads/scriptaculous-js-1.8.2/lib/prototype.js');
js: "/Users/nickg/Downloads/scriptaculous-js-1.8.2/lib/prototype.js", line 1561: uncaught JavaScript runtime exception: TypeError: Cannot find function toLowerCase in object [object HTMLDocument].
    at /Users/nickg/Downloads/scriptaculous-js-1.8.2/lib/prototype.js:1561
    at client9-env-js/dist/env.rhino.js:6302
    at client9-env-js/dist/env.rhino.js:7079
    at client9-env-js/dist/env.rhino.js:5555
    at /Users/nickg/Downloads/scriptaculous-js-1.8.2/lib/prototype.js:2465

By renaming envjs's Element to _Element it was able to load correctly. But that's ghetto.

Namespaces? Modules?

Reported by nickg · March 15th, 2010 @ 10:16 AM

State: resolved
Milestone: none
Assigned to: nickg nickg

Activity

  1. nickg
    nickg

    update
    so prototype 1.5 is fine
    prototype 1.6 explodes.
    boo

    March 18th, 2010 @ 07:28 PM

  2. nickg
    nickg
    • State changed from new to resolved
    • Assigned user set to nickg

    April 27th, 2010 @ 05:34 AM

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.