lib/imba/dom/reconciler.js
function(root,new$,old,caret) {
	
	// var skipnew = new == null or new === false or new === true
	var newIsNull = new$ == null || new$ === false;
	var oldIsNull = old == null || old === false;
	
	
	if (new$ === old) {
		// remember that the caret must be an actual dom element
		// we should instead move the actual caret? - trust
		if (newIsNull) {
			return caret;
		} else if (new$._slot_) {
			return new$._slot_;
		} else if ((new$ instanceof Array) && new$.taglen != null) {
			return reconcileIndexedArray(root,new$,old,caret);
		} else {
			return caret ? caret.nextSibling : root._dom.firstChild;
		};
	} else if (new$ instanceof Array) {
		if (old instanceof Array) {
			// look for slot instead?
			var typ = new$.static;
			if (typ || old.static) {
				// if the static is not nested - we could get a hint from compiler
				// and just skip it
				if (typ == old.static) { // should also include a reference?
					for (var i = 0, items = iter$(new$), len = items.length; i < len; i++) {
						// this is where we could do the triple equal directly
						caret = reconcileNested(root,items[i],old[i],caret);
					};
					return caret;
				} else {
					removeNested(root,old,caret);
				};
				
				// if they are not the same we continue through to the default
			} else {
				// Could use optimized loop if we know that it only consists of nodes
				return reconcileCollection(root,new$,old,caret);
			};
		} else if (!oldIsNull) {
			if (old._slot_) {
				root.removeChild(old);
			} else {
				// old was a string-like object?
				root.removeChild(caret ? caret.nextSibling : root._dom.firstChild);
			};
		};
		
		return self.insertNestedAfter(root,new$,caret);
		// remove old
	} else if (!newIsNull && new$._slot_) {
		if (!oldIsNull) { removeNested(root,old,caret) };
		return self.insertNestedAfter(root,new$,caret);
	} else if (newIsNull) {
		if (!oldIsNull) { removeNested(root,old,caret) };
		return caret;
	} else {
		// if old did not exist we need to add a new directly
		var nextNode;
		// if old was array or imbatag we need to remove it and then add
		if (old instanceof Array) {
			removeNested(root,old,caret);
		} else if (old && old._slot_) {
			root.removeChild(old);
		} else if (!oldIsNull) {
			// ...
			nextNode = caret ? caret.nextSibling : root._dom.firstChild;
			if ((nextNode instanceof Text) && nextNode.textContent != new$) {
				nextNode.textContent = new$;
				return nextNode;
			};
		};
		
		// now add the textnode
		return self.insertNestedAfter(root,new$,caret);
	};
}
function(root,new$,old,caret) {
	
	// var skipnew = new == null or new === false or new === true
	var newIsNull = new$ == null || new$ === false;
	var oldIsNull = old == null || old === false;
	
	
	if (new$ === old) {
		// remember that the caret must be an actual dom element
		// we should instead move the actual caret? - trust
		if (newIsNull) {
			return caret;
		} else if (new$._slot_) {
			return new$._slot_;
		} else if ((new$ instanceof Array) && new$.taglen != null) {
			return reconcileIndexedArray(root,new$,old,caret);
		} else {
			return caret ? caret.nextSibling : root._dom.firstChild;
		};
	} else if (new$ instanceof Array) {
		if (old instanceof Array) {
			// look for slot instead?
			var typ = new$.static;
			if (typ || old.static) {
				// if the static is not nested - we could get a hint from compiler
				// and just skip it
				if (typ == old.static) { // should also include a reference?
					for (var i = 0, items = iter$(new$), len = items.length; i < len; i++) {
						// this is where we could do the triple equal directly
						caret = reconcileNested(root,items[i],old[i],caret);
					};
					return caret;
				} else {
					removeNested(root,old,caret);
				};
				
				// if they are not the same we continue through to the default
			} else {
				// Could use optimized loop if we know that it only consists of nodes
				return reconcileCollection(root,new$,old,caret);
			};
		} else if (!oldIsNull) {
			if (old._slot_) {
				root.removeChild(old);
			} else {
				// old was a string-like object?
				root.removeChild(caret ? caret.nextSibling : root._dom.firstChild);
			};
		};
		
		return self.insertNestedAfter(root,new$,caret);
		// remove old
	} else if (!newIsNull && new$._slot_) {
		if (!oldIsNull) { removeNested(root,old,caret) };
		return self.insertNestedAfter(root,new$,caret);
	} else if (newIsNull) {
		if (!oldIsNull) { removeNested(root,old,caret) };
		return caret;
	} else {
		// if old did not exist we need to add a new directly
		var nextNode;
		// if old was array or imbatag we need to remove it and then add
		if (old instanceof Array) {
			removeNested(root,old,caret);
		} else if (old && old._slot_) {
			root.removeChild(old);
		} else if (!oldIsNull) {
			// ...
			nextNode = caret ? caret.nextSibling : root._dom.firstChild;
			if ((nextNode instanceof Text) && nextNode.textContent != new$) {
				nextNode.textContent = new$;
				return nextNode;
			};
		};
		
		// now add the textnode
		return self.insertNestedAfter(root,new$,caret);
	};
}
function ( root , new$ , old , caret ) { // var skipnew = new == null or new === false or new === true var newIsNull = new$ == null || new$ === false ; var oldIsNull = old == null || old === false ; if ( new$ === old ) { // remember that the caret must be an actual dom element // we should instead move the actual caret? - trust if ( newIsNull ) { return caret ; } else if ( new$ . _slot_ ) { return new$ . _slot_ ; } else if ( ( new$ instanceof Array ) && new$ . taglen != null ) { return reconcileIndexedArray ( root , new$ , old , caret ) ; } else { return caret ? caret . nextSibling : root . _dom . firstChild ; } ; } else if ( new$ instanceof Array ) { if ( old instanceof Array ) { // look for slot instead? var typ = new$ . static ; if ( typ || old . static ) { // if the static is not nested - we could get a hint from compiler // and just skip it if ( typ == old . static ) { // should also include a reference? for ( var i = 0 , items = iter$ ( new$ ) , len = items . length ; i < len ; i ++ ) { // this is where we could do the triple equal directly caret = reconcileNested ( root , items [ i ] , old [ i ] , caret ) ; } ; return caret ; } else { removeNested ( root , old , caret ) ; } ; // if they are not the same we continue through to the default } else { // Could use optimized loop if we know that it only consists of nodes return reconcileCollection ( root , new$ , old , caret ) ; } ; } else if ( ! oldIsNull ) { if ( old . _slot_ ) { root . removeChild ( old ) ; } else { // old was a string-like object? root . removeChild ( caret ? caret . nextSibling : root . _dom . firstChild ) ; } ; } ; return self . insertNestedAfter ( root , new$ , caret ) ; // remove old } else if ( ! newIsNull && new$ . _slot_ ) { if ( ! oldIsNull ) { removeNested ( root , old , caret ) } ; return self . insertNestedAfter ( root , new$ , caret ) ; } else if ( newIsNull ) { if ( ! oldIsNull ) { removeNested ( root , old , caret ) } ; return caret ; } else { // if old did not exist we need to add a new directly var nextNode ; // if old was array or imbatag we need to remove it and then add if ( old instanceof Array ) { removeNested ( root , old , caret ) ; } else if ( old && old . _slot_ ) { root . removeChild ( old ) ; } else if ( ! oldIsNull ) { // ... nextNode = caret ? caret . nextSibling : root . _dom . firstChild ; if ( ( nextNode instanceof Text ) && nextNode . textContent != new$ ) { nextNode . textContent = new$ ; return nextNode ; } ; } ; // now add the textnode return self . insertNestedAfter ( root , new$ , caret ) ; } ; }
the general reconciler that respects conditions etc caret is the current node we want to insert things after
the general reconciler that respects conditions etc caret is the current node we want to insert things after