jQuery without a DOM

If you’re ever using jQuery without a proper DOM, you may want to use this. It provides enough of a DOM-like syntax to suffice. (Literally, this is every function which jQuery calls on the DOM directly (assuming no selectors). I really wish they abstracted the AJAX functionality so that it would be trivial to use it without the whole framework)

var emptyFunction = function(){ return ""; },
      gebi = function(elm){
				return {
					nodeType: '',
					innerHTML: '',
					insertBefore: emptyFunction,
					removeChild: emptyFunction,
					appendChild: emptyFunction,
					getAttribute: emptyFunction,
					setAttribute: emptyFunction,
					getElementsByTagName: function(){
						return {};
					},
					style: {}
				};
		}
window = {
	document:{
		getElementById: gebi,
		createComment: emptyFunction,
		createElement: gebi,
		createDocumentFragment: gebi,
		documentElement: ntx.extend( {
			createElement: gebi,
			childNodes:(function(){
				var g = gebi();
				return [g]
			})()
		}, gebi() )
	},
	location: {
		href:""
	},
	navigator:{
		userAgent: ""
	}
};
This entry was posted in Uncategorized and tagged , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>