Commits

Stephen McKamey committed 0e038ae

- fixing JSLint warnings
- prepping for src splitting

  • Participants
  • Parent commits bf90d74

Comments (0)

Files changed (2)

 
 var duel = (function() {
 
-	/* Const --------------------*/
+	/* types.js --------------------*/
 
 	/**
 	 * @type {string}
 	var RAW = 5;
 
 	/**
+	 * Wraps a data value to maintain as raw markup in output
+	 * 
+	 * @this {Markup}
+	 * @param {string} value The value
+	 * @constructor
+	 */
+	function Markup(value) {
+		/**
+		 * @type {string}
+		 * @const
+		 * @protected
+		 */
+		this.value = value;
+	}
+
+	/**
+	 * Renders the value
+	 * 
+	 * @override
+	 * @this {Markup}
+	 * @returns {string} value
+	 */
+	Markup.prototype.toString = function() {
+		return this.value;
+	};
+
+	/**
 	 * Determines the type of the value
 	 * 
 	 * @param {*} val the object being tested
 		}
 	}
 
-	/* Binding methods --------------------*/
+	/**
+	 * Wraps a binding result with rendering methods
+	 * 
+	 * @this {Result}
+	 * @param {Array|Object|string|number} view The result tree
+	 * @constructor
+	 */
+	function Result(view) {
+		if (getType(view) !== ARY) {
+			// ensure is rooted element
+			view = ["", view];
+		}
 
+		/**
+		 * @type {Array}
+		 * @const
+		 * @protected
+		 */
+		// Closure Compiler type cast
+		this.value = /** @type {Array} */(view);
+	}
+
+	/**
+	 * Wraps a template definition with binding methods
+	 * 
+	 * @this {View}
+	 * @param {Array|Object|string|number} view The template definition
+	 * @constructor
+	 */
+	function View(view) {
+		if (getType(view) !== ARY) {
+			// ensure is rooted element
+			view = ["", view];
+		}
+
+		/**
+		 * @type {Array}
+		 * @const
+		 * @protected
+		 */
+		// Closure Compiler type cast
+		this.value = /** @type {Array} */(view);
+	}
+
+	/* bind.js --------------------*/
+
+	var bind;
+	
 	/**
 	 * Appends a node to a parent
 	 * 
 						continue;
 					}
 
-					// clone and bind block
+					// clone and process block
 					if (block.length === 3) {
 						block = block[2];
 					} else {
 					return bind(block, model, index, count);
 
 				case ELSE:
-					// clone and bind block
+					// clone and process block
 					if (block.length === 2) {
 						block = block[1];
 					} else {
 	 * @param {number} count The total number of data items
 	 * @returns {Array|Object|string|number}
 	 */
-	function bind(node, model, index, count) {
+	bind = function(node, model, index, count) {
 		/**
 		 * @type {Array|Object|string|number}
 		 */
 		}
 
 		return result;
-	}
+	};
 
-	/* Rendering methods --------------------*/
+	/**
+	 * Binds and wraps the result
+	 * 
+	 * @this {View}
+	 * @param {*} model The data item being bound
+	 */
+	View.prototype.bind = function(model) {
+		var result = bind(this.value, model, 0, 1);
+		return new Result(result);
+	};
+
+	/* render.js --------------------*/
 
 	/**
 	 * Void tag lookup 
 			child;
 
 		if (tag) {
-			// render open tag
+			// emit open tag
 			output.push('<', tag);
 
 			child = node[i];
 			if (getType(child) === OBJ) {
-				// render attributes
+				// emit attributes
 				for (var name in child) {
 					if (child.hasOwnProperty(name)) {
 						output.push(' ', name);
 			output.push('>');
 		}
 
-		// render children
+		// emit children
 		for (; i<length; i++) {
 			child = node[i];
 			if (getType(child) === ARY) {
 		}
 
 		if (tag && !VOID_TAGS[tag]) {
-			// render close tag
+			// emit close tag
 			output.push('</', tag, '>');
 		}
 	}
 	/**
 	 * Renders the result as a string
 	 * 
-	 * @param {Array|Object|string|number} view The compiled view
+	 * @param {Array} view The compiled view
 	 * @returns {string}
 	 */
 	 function render(view) {
-		if (getType(view) !== ARY) {
-			// encode string literals
-			return "" + htmlEncode(view);
-		}
-
 		var output = [];
-		// Closure Compiler type cast
-		renderElem(output, /** @type {Array} */ (view));
+		renderElem(output, view);
 		return output.join("");
 	}
 
-	/* DOM Building methods --------------------*/
+	/**
+	 * Returns result as HTML text
+	 * 
+	 * @override
+	 * @this {Result}
+	 * @returns {string}
+	 */
+	Result.prototype.toString = function() {
+		return render(this.value);
+	};
+
+	/**
+	 * Returns result as HTML text
+	 * 
+	 * @override
+	 * @this {Result}
+	 * @returns {string}
+	 */
+	View.prototype.toString = function() {
+		return render(this.value);
+	};
+
+	/* dom.js --------------------*/
 
 	/**
 	 * Attribute name map
 	})("blur,change,click,dblclick,error,focus,keydown,keypress,keyup,load,mousedown,mouseenter,mouseleave,mousemove,mouseout,mouseover,mouseup,resize,scroll,select,submit,unload".split(','));
 
 	/**
+	 * Creates a DOM element 
+	 * 
+	 * @param {string} tag The element's tag name
+	 * @returns {Node}
+	 */
+	function createElement(tag) {
+		if (!tag) {
+			// create a document fragment to hold multiple-root elements
+			if (document.createDocumentFragment) {
+				return document.createDocumentFragment();
+			}
+
+			tag = "";
+		}
+
+		if (tag.toLowerCase() === "style" && document.createStyleSheet) {
+			// IE requires this interface for styles
+			return document.createStyleSheet();
+		}
+
+		return document.createElement(tag);
+	}
+
+	/**
 	 * Appends a child to an element
 	 * 
 	 * @param {Node} elem The parent element
 	 * @param {Node} child The child
 	 */
-	function appendChild(elem, child) {
+	function appendDOM(elem, child) {
 		if (child) {
 			if (elem.tagName && elem.tagName.toLowerCase() === "table" && elem.tBodies) {
 				if (!child.tagName) {
 					// must unwrap documentFragment for tables
 					if (child.nodeType === 11) {
 						while (child.firstChild) {
-							appendChild(elem, child.removeChild(child.firstChild));
+							appendDOM(elem, child.removeChild(child.firstChild));
 						}
 					}
 					return;
 					// insert in last tbody
 					var tBody = elem.tBodies.length > 0 ? elem.tBodies[elem.tBodies.length-1] : null;
 					if (!tBody) {
-						tBody = document.createElement(childTag === "th" ? "thead" : "tbody");
+						tBody = createElement(childTag === "th" ? "thead" : "tbody");
 						elem.appendChild(tBody);
 					}
 					tBody.appendChild(child);
 		if (attr.name && document.attachEvent) {
 			try {
 				// IE fix for not being able to programatically change the name attribute
-				var alt = document.createElement("<"+elem.tagName+" name='"+attr.name+"'>");
+				var alt = createElement("<"+elem.tagName+" name='"+attr.name+"'>");
 				// fix for Opera 8.5 and Netscape 7.1 creating malformed elements
 				if (elem.tagName === alt.tagName) {
 					elem = alt;
 	 * @returns {Node}
 	 */
 	function toDOM(value) {
-		var wrapper = document.createElement("div");
+		var wrapper = createElement("div");
 		wrapper.innerHTML = ""+value;
 
 		// trim extraneous whitespace
 		}
 
 		// create a document fragment to hold elements
-		var frag = document.createDocumentFragment ?
-			document.createDocumentFragment() :
-			document.createElement("");
-
+		var frag = createElement("");
 		while (wrapper.firstChild) {
 			frag.appendChild(wrapper.firstChild);
 		}
 	function onError(ex) {
 		return document.createTextNode("["+ex+"]");
 	}
-
+	
 	/**
 	 * Applies node to DOM
 	 * 
 	 * @param {Node} elem The element to append
-	 * @param {Array|Object|string|number} node The node to build
+	 * @param {Array} node The node to populate
 	 * @returns {Node}
 	 */
-	function patch(elem, node) {
-
+	function patchDOM(elem, node) {
 		for (var i=1; i<node.length; i++) {
 			var child = node[i];
 			switch (getType(child)) {
 				case ARY:
+					// append child element
+					appendDOM(elem, patchDOM(createElement(child[0]), child));
+					break;
 				case VAL:
-					// append children
-					appendChild(elem, build(child));
+					// append child value
+					appendDOM(elem, document.createTextNode(""+child));
 					break;
 				case OBJ:
 					if (elem.nodeType === 1) {
 					}
 					break;
 				case RAW:
-					appendChild(elem, toDOM(child));
+					appendDOM(elem, toDOM(child));
 					break;
 			}
 		}
 
+		// trim extraneous whitespace
+		trimWhitespace(elem);
+
+		// trigger callbacks
+		onInit(elem);
+
+		// eliminate wrapper for single nodes
+		if (elem.nodeType === 11 && elem.childNodes.length === 1) {
+			elem = elem.firstChild;
+		}
+
 		return elem;
 	}
 
 	/**
-	 * Builds the result as DOM
-	 * 
-	 * @param {Array|Object|string|number} view The bound view
-	 * @returns {Node}
-	 */
-	function build(view) {
-		try {
-			if (!view) {
-				return null;
-			}
-			if (typeof view === "string") {
-				return document.createTextNode(view);
-			}
-			if (view instanceof Markup) {
-				return toDOM(view);
-			}
-
-			var tag = view[0]; // tagName
-			if (!tag) {
-				// correctly handle multiple-roots
-				// create a document fragment to hold elements
-				var frag = document.createDocumentFragment ?
-					document.createDocumentFragment() :
-					document.createElement("");
-				for (var i=1; i<view.length; i++) {
-					appendChild(frag, build(view[i]));
-				}
-
-				// trim extraneous whitespace
-				trimWhitespace(frag);
-
-				// eliminate wrapper for single nodes
-				if (frag.childNodes.length === 1) {
-					return frag.firstChild;
-				}
-				return frag;
-			}
-
-			if (tag.toLowerCase() === "style" && document.createStyleSheet) {
-				// IE requires this interface for styles
-				patch(document.createStyleSheet(), view);
-				// in IE styles are effective immediately
-				return null;
-			}
-
-			var elem = patch(document.createElement(tag), view);
-
-			// trim extraneous whitespace
-			trimWhitespace(elem);
-
-			// trigger callbacks
-			onInit(elem);
-
-			return elem;
-		} catch (ex) {
-			try {
-				// handle error with complete context
-				var err = (typeof duel.onerror === "function") ? duel.onerror : onError;
-				return err(ex, view);
-			} catch (ex2) {
-				return onError(ex2);
-			}
-		}
-	}
-
-	/* Types --------------------*/
-
-	/**
-	 * Wraps a data value to maintain as raw markup in output
-	 * 
-	 * @this {Markup}
-	 * @param {string} value The value
-	 * @constructor
-	 */
-	function Markup(value) {
-		/**
-		 * @type {string}
-		 * @const
-		 * @protected
-		 */
-		this.value = value;
-	}
-
-	/**
-	 * Renders the value
-	 * 
-	 * @override
-	 * @this {Markup}
-	 * @returns {string} value
-	 */
-	Markup.prototype.toString = function() {
-		return this.value;
-	};
-
-	/**
-	 * Wraps a binding result with rendering methods
-	 * 
-	 * @this {Result}
-	 * @param {Array|Object|string|number} view The result tree
-	 * @constructor
-	 */
-	function Result(view) {
-		/**
-		 * @type {Array|Object|string|number}
-		 * @const
-		 * @protected
-		 */
-		this.value = view;
-	}
-
-	/**
 	 * Returns result as DOM objects
 	 * 
 	 * @this {Result}
 	 * @returns {Node}
 	 */
 	Result.prototype.toDOM = function() {
-		return build(this.value);
+		try {
+			return patchDOM(createElement(this.value[0]), this.value);
+		} catch (ex) {
+			try {
+				// handle error with complete context
+				var err = (typeof duel.onerror === "function") ? duel.onerror : onError;
+				return err(ex, this.value);
+			} catch (ex2) {
+				return onError(ex2);
+			}
+		}
+
 //		return toDOM(render(this.value));
 	};
 
-	/**
-	 * Returns result as HTML text
-	 * 
-	 * @override
-	 * @this {Result}
-	 * @returns {string}
-	 */
-	Result.prototype.toString = function() {
-		return render(this.value);
-	};
-
-	/**
-	 * Wraps a template definition with binding methods
-	 * 
-	 * @this {View}
-	 * @param {Array|Object|string|number} view The template definition
-	 * @constructor
-	 */
-	function View(view) {
-		/**
-		 * @type {Array|Object|string|number}
-		 * @const
-		 * @protected
-		 */
-		this.value = view;
-	}
-
-	/**
-	 * Binds and wraps the result
-	 * 
-	 * @this {View}
-	 * @param {*} model The data item being bound
-	 */
-	View.prototype.bind = function(model) {
-		var result = bind(this.value, model, 0, 1);
-		return new Result(result);
-	};
-
-	/**
-	 * Returns result as HTML text
-	 * 
-	 * @override
-	 * @this {Result}
-	 * @returns {string}
-	 */
-	View.prototype.toString = function() {
-		return render(this.value);
-	};
-
-	/* Factory methods --------------------*/
+	/* factory.js --------------------*/
 
 	/**
 	 * @param {Array|Object|string|number|function(*,number,number):Array|Object|string} view The view template

File src/duel.min.js

-var duel=function(){function j(a){switch(typeof a){case "object":return!a?0:a instanceof Array?2:a instanceof n?5:3;case "function":return 1;case "undefined":return 0;default:return 4}}function o(a,b){if(j(a)===2)switch(j(b)){case 2:if(b[0]==="")for(var c=1,e=b.length;c<e;c++)o(a,b[c]);else a.push(b);break;case 3:c=a[1];if(j(c)===3)for(e in b){if(b.hasOwnProperty(e))c[e]=b[e]}else a.splice(1,0,b);break;case 4:c=a.length-1;if(c>0&&j(a[c])===4)a[c]=""+a[c]+b;else a.push(""+b);break;case 0:break;default:a.push(b)}}
-function u(a,b,c,e){for(var d=1,f=a.length;d<f;d++){var h=a[d],g=h[1];switch(h[0]){case "$if":var i=g&&g.test;if(j(g.test)===1)i=i(b,c,e);if(!i)continue;if(h.length===3)h=h[2];else[""].concat(a.slice(2));return k(h,b,c,e);case "$else":if(h.length===2)h=h[1];else[""].concat(a.slice(1));return k(h,b,c,e)}}return null}function k(a,b,c,e){var d;switch(j(a)){case 1:d=a(b,c,e);break;case 2:var f=a[0]||"";switch(f){case "$for":a=a;f=a[1];if(!f||!f.each)d=null;else{b=j(f.each)===1?f.each(b,c,e):f.each;a=
-a.length===3?a[2]:[""].concat(a.slice(2));c=[""];switch(j(b)){case 2:e=0;for(d=b.length;e<d;e++)o(c,k(a,b[e],e,d));break;case 3:for(d in b)b.hasOwnProperty(d)&&o(c,k(a,b[d],d,0))}d=c}break;case "$choose":d=u(a,b,c,e);break;case "$if":case "$else":d=u(["$choose",a],b,c,e);break;case "$call":var h=a[1];if(h){d=k(h.view,b,c,e);a=k(h.model,b,c,e);f=k(h.index,b,c,e);b=k(h.count,b,c,e);d=k(m(d).value,a,f,b)}else d=null;break;default:d=[f];f=1;for(h=a.length;f<h;f++)o(d,k(a[f],b,c,e))}break;case 3:d={};
-for(f in a)if(a.hasOwnProperty(f))d[f]=k(a[f],b,c,e);break;default:d=a}return d}function v(a){if(typeof a!=="string")return a;return a.replace(/[&<>]/g,function(b){switch(b){case "&":return"&amp;";case "<":return"&lt;";case ">":return"&gt;";default:return b}})}function E(a){if(typeof a!=="string")return a;return a.replace(/[&<>"]/g,function(b){switch(b){case "&":return"&amp;";case "<":return"&lt;";case ">":return"&gt;";case '"':return"&quot;";default:return b}})}function w(a,b){var c=b[0],e=b.length,
-d=1,f;if(c){a.push("<",c);f=b[d];if(j(f)===3){for(var h in f)if(f.hasOwnProperty(h)){a.push(" ",h);var g=f[h];g&&a.push('="',E(g),'"')}d++}a.push(">")}for(;d<e;d++){f=b[d];j(f)===2?w(a,f):a.push(v(f))}c&&!F[c]&&a.push("</",c,">")}function x(a){if(j(a)!==2)return""+v(a);var b=[];w(b,a);return b.join("")}function p(a,b){if(b)if(a.tagName&&a.tagName.toLowerCase()==="table"&&a.tBodies)if(b.tagName){var c=b.tagName.toLowerCase();if(c&&c!=="tbody"&&c!=="thead"){var e=a.tBodies.length>0?a.tBodies[a.tBodies.length-
-1]:null;if(!e){e=document.createElement(c==="th"?"thead":"tbody");a.appendChild(e)}e.appendChild(b)}else a.canHaveChildren!==false&&a.appendChild(b)}else{if(b.nodeType===11)for(;b.firstChild;)p(a,b.removeChild(b.firstChild))}else if(a.tagName&&a.tagName.toLowerCase()==="style"&&document.createStyleSheet)a.cssText=b;else if(a.canHaveChildren!==false)a.appendChild(b);else if(a.tagName&&a.tagName.toLowerCase()==="object"&&b.tagName&&b.tagName.toLowerCase()==="param"){try{a.appendChild(b)}catch(d){}try{if(a.object)a.object[b.name]=
-b.value}catch(f){}}}function y(a,b,c){if(typeof c==="string")c=new Function("event",c);if(typeof c==="function")a[b]=c}function z(a){return!!a&&a.nodeType===3&&(!a.nodeValue||!/\S/.exec(a.nodeValue))}function r(a){if(a){for(;z(a.firstChild);)a.removeChild(a.firstChild);for(;z(a.lastChild);)a.removeChild(a.lastChild)}}function A(a){var b=document.createElement("div");b.innerHTML=""+a;r(b);if(b.childNodes.length===1)return b.firstChild;for(a=document.createDocumentFragment?document.createDocumentFragment():
-document.createElement("");b.firstChild;)a.appendChild(b.firstChild);return a}function B(a,b){var c=a[b];if(c){try{delete a[b]}catch(e){a[b]=undefined}if(typeof c!=="function")try{c=new Function(""+c)}catch(d){c=null}}return c}function G(a){if(a){var b=B(a,"$init");b&&b.call(a);if(b=B(a,"$load"))setTimeout(function(){b.call(a);b=a=null},0);else b=a=null}}function C(a){return document.createTextNode("["+a+"]")}function D(a,b){for(var c=1;c<b.length;c++){var e=b[c];switch(j(e)){case 2:case 4:p(a,s(e));
-break;case 3:if(a.nodeType===1){var d=a;e=e;if(e.name&&document.attachEvent)try{var f=document.createElement("<"+d.tagName+" name='"+e.name+"'>");if(d.tagName===f.tagName)d=f}catch(h){}var g=void 0;for(g in e)if(e.hasOwnProperty(g)){var i=e[g];if(g&&i){g=H[g.toLowerCase()]||g;if(g==="style")if(typeof d.style.cssText!=="undefined")d.style.cssText=i;else d.style=i;else if(g==="class")d.className=i;else if(I[g]){y(d,g,i);l[g]&&y(d,l[g],i)}else if(j(i)===4){d.setAttribute(g,i);l[g]&&d.setAttribute(l[g],
-i)}else{d[g]=i;if(l[g])d[l[g]]=i}}}a=d}break;case 5:p(a,A(e))}}return a}function s(a){try{if(!a)return null;if(typeof a==="string")return document.createTextNode(a);if(a instanceof n)return A(a);var b=a[0];if(!b){var c=document.createDocumentFragment?document.createDocumentFragment():document.createElement("");for(b=1;b<a.length;b++)p(c,s(a[b]));r(c);if(c.childNodes.length===1)return c.firstChild;return c}if(b.toLowerCase()==="style"&&document.createStyleSheet){D(document.createStyleSheet(),a);return null}var e=
-D(document.createElement(b),a);r(e);G(e);return e}catch(d){try{return(typeof m.onerror==="function"?m.onerror:C)(d,a)}catch(f){return C(f)}}}function n(a){this.value=a}function t(a){this.value=a}function q(a){this.value=a}var F=function(a){for(var b={};a.length;)b[a.pop()]=true;return b}("area,base,basefont,br,col,frame,hr,img,input,isindex,keygen,link,meta,param,source,wbr".split(",")),H={rowspan:"rowSpan",colspan:"colSpan",cellpadding:"cellPadding",cellspacing:"cellSpacing",tabindex:"tabIndex",
-accesskey:"accessKey",hidefocus:"hideFocus",usemap:"useMap",maxlength:"maxLength",readonly:"readOnly",contenteditable:"contentEditable"},l={enctype:"encoding",onscroll:"DOMMouseScroll"},I=function(a){for(var b={};a.length;){var c=a.pop();b["on"+c.toLowerCase()]=c}return b}("blur,change,click,dblclick,error,focus,keydown,keypress,keyup,load,mousedown,mouseenter,mouseleave,mousemove,mouseout,mouseover,mouseup,resize,scroll,select,submit,unload".split(","));n.prototype.toString=function(){return this.value};
-t.prototype.toDOM=function(){return s(this.value)};t.prototype.toString=function(){return x(this.value)};q.prototype.bind=function(a){a=k(this.value,a,0,1);return new t(a)};q.prototype.toString=function(){return x(this.value)};var m=function(a){return a instanceof q?a:new q(a)};m.raw=function(a){return new n(a)};return m}();
+var duel=function(){function r(a){this.value=a}function i(a){switch(typeof a){case "object":return!a?0:a instanceof Array?2:a instanceof r?5:3;case "function":return 1;case "undefined":return 0;default:return 4}}function s(a){if(i(a)!==2)a=["",a];this.value=a}function o(a){if(i(a)!==2)a=["",a];this.value=a}function p(a,b){if(i(a)===2)switch(i(b)){case 2:if(b[0]==="")for(var d=1,c=b.length;d<c;d++)p(a,b[d]);else a.push(b);break;case 3:d=a[1];if(i(d)===3)for(c in b){if(b.hasOwnProperty(c))d[c]=b[c]}else a.splice(1,
+0,b);break;case 4:d=a.length-1;if(d>0&&i(a[d])===4)a[d]=""+a[d]+b;else a.push(""+b);break;case 0:break;default:a.push(b)}}function t(a,b,d,c){for(var e=1,f=a.length;e<f;e++){var g=a[e],k=g[1];switch(g[0]){case "$if":var h=k&&k.test;if(i(k.test)===1)h=h(b,d,c);if(!h)continue;if(g.length===3)g=g[2];else[""].concat(a.slice(2));return j(g,b,d,c);case "$else":if(g.length===2)g=g[1];else[""].concat(a.slice(1));return j(g,b,d,c)}}return null}function C(a){if(typeof a!=="string")return a;return a.replace(/[&<>]/g,
+function(b){switch(b){case "&":return"&amp;";case "<":return"&lt;";case ">":return"&gt;";default:return b}})}function D(a){if(typeof a!=="string")return a;return a.replace(/[&<>"]/g,function(b){switch(b){case "&":return"&amp;";case "<":return"&lt;";case ">":return"&gt;";case '"':return"&quot;";default:return b}})}function u(a,b){var d=b[0],c=b.length,e=1,f;if(d){a.push("<",d);f=b[e];if(i(f)===3){for(var g in f)if(f.hasOwnProperty(g)){a.push(" ",g);var k=f[g];k&&a.push('="',D(k),'"')}e++}a.push(">")}for(;e<
+c;e++){f=b[e];i(f)===2?u(a,f):a.push(C(f))}d&&!E[d]&&a.push("</",d,">")}function v(a){var b=[];u(b,a);return b.join("")}function l(a){if(!a){if(document.createDocumentFragment)return document.createDocumentFragment();a=""}if(a.toLowerCase()==="style"&&document.createStyleSheet)return document.createStyleSheet();return document.createElement(a)}function q(a,b){if(b)if(a.tagName&&a.tagName.toLowerCase()==="table"&&a.tBodies)if(b.tagName){var d=b.tagName.toLowerCase();if(d&&d!=="tbody"&&d!=="thead"){var c=
+a.tBodies.length>0?a.tBodies[a.tBodies.length-1]:null;if(!c){c=l(d==="th"?"thead":"tbody");a.appendChild(c)}c.appendChild(b)}else a.canHaveChildren!==false&&a.appendChild(b)}else{if(b.nodeType===11)for(;b.firstChild;)q(a,b.removeChild(b.firstChild))}else if(a.tagName&&a.tagName.toLowerCase()==="style"&&document.createStyleSheet)a.cssText=b;else if(a.canHaveChildren!==false)a.appendChild(b);else if(a.tagName&&a.tagName.toLowerCase()==="object"&&b.tagName&&b.tagName.toLowerCase()==="param"){try{a.appendChild(b)}catch(e){}try{if(a.object)a.object[b.name]=
+b.value}catch(f){}}}function w(a,b,d){if(typeof d==="string")d=new Function("event",d);if(typeof d==="function")a[b]=d}function x(a){return!!a&&a.nodeType===3&&(!a.nodeValue||!/\S/.exec(a.nodeValue))}function y(a){if(a){for(;x(a.firstChild);)a.removeChild(a.firstChild);for(;x(a.lastChild);)a.removeChild(a.lastChild)}}function z(a,b){var d=a[b];if(d){try{delete a[b]}catch(c){a[b]=undefined}if(typeof d!=="function")try{d=new Function(""+d)}catch(e){d=null}}return d}function F(a){if(a){var b=z(a,"$init");
+b&&b.call(a);if(b=z(a,"$load"))setTimeout(function(){b.call(a);b=a=null},0);else b=a=null}}function A(a){return document.createTextNode("["+a+"]")}function B(a,b){for(var d=1;d<b.length;d++){var c=b[d];switch(i(c)){case 2:q(a,B(l(c[0]),c));break;case 4:q(a,document.createTextNode(""+c));break;case 3:if(a.nodeType===1){var e=a,f=c;if(f.name&&document.attachEvent)try{var g=l("<"+e.tagName+" name='"+f.name+"'>");if(e.tagName===g.tagName)e=g}catch(k){}c=void 0;for(c in f)if(f.hasOwnProperty(c)){var h=
+f[c];if(c&&h){c=G[c.toLowerCase()]||c;if(c==="style")if(typeof e.style.cssText!=="undefined")e.style.cssText=h;else e.style=h;else if(c==="class")e.className=h;else if(H[c]){w(e,c,h);m[c]&&w(e,m[c],h)}else if(i(h)===4){e.setAttribute(c,h);m[c]&&e.setAttribute(m[c],h)}else{e[c]=h;if(m[c])e[m[c]]=h}}}a=e}break;case 5:e=q;f=a;h=c;c=l("div");c.innerHTML=""+h;y(c);if(c.childNodes.length===1)c=c.firstChild;else{for(h=l("");c.firstChild;)h.appendChild(c.firstChild);c=h}e(f,c)}}y(a);F(a);if(a.nodeType===
+11&&a.childNodes.length===1)a=a.firstChild;return a}r.prototype.toString=function(){return this.value};var j;j=function(a,b,d,c){var e;switch(i(a)){case 1:e=a(b,d,c);break;case 2:var f=a[0]||"";switch(f){case "$for":a=a;f=a[1];if(!f||!f.each)e=null;else{b=i(f.each)===1?f.each(b,d,c):f.each;a=a.length===3?a[2]:[""].concat(a.slice(2));d=[""];switch(i(b)){case 2:c=0;for(e=b.length;c<e;c++)p(d,j(a,b[c],c,e));break;case 3:for(e in b)b.hasOwnProperty(e)&&p(d,j(a,b[e],e,0))}e=d}break;case "$choose":e=t(a,
+b,d,c);break;case "$if":case "$else":e=t(["$choose",a],b,d,c);break;case "$call":var g=a[1];if(g){e=j(g.view,b,d,c);a=j(g.model,b,d,c);f=j(g.index,b,d,c);b=j(g.count,b,d,c);e=j(n(e).value,a,f,b)}else e=null;break;default:e=[f];f=1;for(g=a.length;f<g;f++)p(e,j(a[f],b,d,c))}break;case 3:e={};for(f in a)if(a.hasOwnProperty(f))e[f]=j(a[f],b,d,c);break;default:e=a}return e};o.prototype.bind=function(a){a=j(this.value,a,0,1);return new s(a)};var E=function(a){for(var b={};a.length;)b[a.pop()]=true;return b}("area,base,basefont,br,col,frame,hr,img,input,isindex,keygen,link,meta,param,source,wbr".split(","));
+s.prototype.toString=function(){return v(this.value)};o.prototype.toString=function(){return v(this.value)};var G={rowspan:"rowSpan",colspan:"colSpan",cellpadding:"cellPadding",cellspacing:"cellSpacing",tabindex:"tabIndex",accesskey:"accessKey",hidefocus:"hideFocus",usemap:"useMap",maxlength:"maxLength",readonly:"readOnly",contenteditable:"contentEditable"},m={enctype:"encoding",onscroll:"DOMMouseScroll"},H=function(a){for(var b={};a.length;){var d=a.pop();b["on"+d.toLowerCase()]=d}return b}("blur,change,click,dblclick,error,focus,keydown,keypress,keyup,load,mousedown,mouseenter,mouseleave,mousemove,mouseout,mouseover,mouseup,resize,scroll,select,submit,unload".split(","));
+s.prototype.toDOM=function(){try{return B(l(this.value[0]),this.value)}catch(a){try{return(typeof n.onerror==="function"?n.onerror:A)(a,this.value)}catch(b){return A(b)}}};var n=function(a){return a instanceof o?a:new o(a)};n.raw=function(a){return new r(a)};return n}();