module.exports = function(data){
	var later = setTimeout;

	function getEither(propName, moduleName) {
		return (data.modules && data.modules[propName]) || require(moduleName);
	}

	var getDomMutate = getEither.bind(null, "domMutate", "can-dom-mutate/node");

	return {
		ended: function(){
			var domMutate = getDomMutate();

			var docEl = data.document.documentElement;

			// Run the removal within the zone so that the globals point to our globals.
			var removeDocumentElement = this.wrap(function() {
				var newDocEl = data.document.createElement("html");
				domMutate.replaceChild.call(data.document, newDocEl, docEl);
			});

			// Do this some time later to prevent extra mutations
			// In the mutation stream
			later(removeDocumentElement);
		}
	};
};

var nodeLists = require("can-view-nodelist");
module.exports = function(data){
	var later = setTimeout;

	function getEither(propName, moduleName) {
		return (data.modules && data.modules[propName]) || require(moduleName);
	}

	var getDomMutate = getEither.bind(null, "domMutate", "can-dom-mutate/node");
	return {
		ended: function(){
			var domMutate = getDomMutate();

			var docEl = data.document.documentElement;

			// Run the removal within the zone so that the globals point to our globals.
			var removeDocumentElement = this.wrap(function() {
				if(!data.modules) {
					return;
				}
				var main = data.modules.main;
				nodeLists.unregister(main.nodeList);
				
				var newDocEl = data.document.createElement("html");
				domMutate.replaceChild.call(data.document, newDocEl, docEl);
			});

			// Do this some time later to prevent extra mutations
			// In the mutation stream
			later(removeDocumentElement);
		}
	};
};

Add a nodelist unregistr when the document element is removed
Add a nodelist unregistr when the document element is removed
