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?