Make Element constructor creation cleaner.

This commit is contained in:
Tobie Langel 2008-12-11 04:17:54 +01:00
parent 51d0181d29
commit b74eeeb757
1 changed files with 6 additions and 6 deletions

View File

@ -42,9 +42,9 @@ if (!Node.ELEMENT_NODE) {
});
}
(function() {
var element = this.Element;
this.Element = function(tagName, attributes) {
(function(global) {
var element = global.Element;
global.Element = function(tagName, attributes) {
attributes = attributes || { };
tagName = tagName.toLowerCase();
var cache = Element.cache;
@ -56,9 +56,9 @@ if (!Node.ELEMENT_NODE) {
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);
Object.extend(global.Element, element || { });
if (element) global.Element.prototype = element.prototype;
})(this);
Element.cache = { };