<commit_before>"use strict"

var Vnode = require("../render/vnode")
var autoredraw = require("../api/autoredraw")
var dummy = {view: function() {}}

module.exports = function(renderer, pubsub) {
	return function(root, component) {
		pubsub.unsubscribe(root.redraw)

		var run = autoredraw(root, renderer, pubsub, function() {
			renderer.render(
				root,
				Vnode(component === null ? dummy : component, undefined, undefined, undefined, undefined, undefined)
			)
		})

		run()

		if (component === null) {
			pubsub.unsubscribe(root.redraw)
			delete root.redraw
		}
	}
}
<commit_msg>Better cleanup when unmounting<commit_after>"use strict"

var Vnode = require("../render/vnode")
var autoredraw = require("../api/autoredraw")

module.exports = function(renderer, pubsub) {
	return function(root, component) {
		pubsub.unsubscribe(root.redraw)
		if (component === null) {
			renderer.render(root, [])
			delete root.redraw
			return
		}

		var run = autoredraw(root, renderer, pubsub, function() {
			renderer.render(
				root,
				Vnode(component, undefined, undefined, undefined, undefined, undefined)
			)
		})

		run()
	}
}

{'fraction_non_alphanumeric': 0.14412024756852343, 'fraction_numerical': 0.0, 'mean_word_length': 3.986784140969163, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2699069', 'n_tokens_mistral': 415, 'n_tokens_neox': 371, 'n_words': 83}