Created
July 13, 2009 23:09
-
-
Save eerne/146516 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Document.implement({ | |
id: (function(){ | |
var types = { | |
string: function(id, nocash, doc){ | |
id = doc.getElementById(id); | |
return (id) ? types.element(id, nocash) : null; | |
}, | |
element: function(el, nocash){ | |
$uid(el); | |
if (!nocash && !el.$family && !(/^object|embed$/i).test(el.tagName)){ | |
var proto = Element.Prototype; | |
for (var p in proto) el[p] = proto[p]; | |
}; | |
return el; | |
}, | |
object: function(obj, nocash, doc){ | |
if (obj.toElement) return types.element(obj.toElement(doc), nocash); | |
return null; | |
} | |
}; | |
types.textnode = types.whitespace = types.window = types.document = $arguments(0); | |
return function(el, nocash, doc){ | |
if (el && el.$family && el.uid) return el; | |
var type = $type(el); | |
return (types[type]) ? types[type](el, nocash, doc || document) : null; | |
}; | |
})() | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment