<commit_before>import { h, Component } from 'preact';

export default function(req) {
	function Async() {
		Component.call(this);

		let b, old;
		this.componentWillMount = () => {
			b = this.base = this.nextBase || this.__b; // short circuits 1st render
			req(m => {
				this.setState({ child: m.default || m });
			});
		};

		this.shouldComponentUpdate = (_, nxt) => {
			nxt = nxt.child === void 0;
			if (nxt && old === void 0 && !!b) {
				old = h(b.nodeName, { dangerouslySetInnerHTML: { __html: b.innerHTML } });
			} else {
				old = ''; // dump it
			}
			return !nxt;
		};

		this.render = (p, s) => s.child ? h(s.child, p) : old;
	}<commit_msg>Bugfix for hydrating async components prerendered to a Text node (#621)<commit_after>import { h, Component } from 'preact';

export default function(req) {
	function Async() {
		Component.call(this);

		let b, old;
		this.componentWillMount = () => {
			b = this.base = this.nextBase || this.__b; // short circuits 1st render
			req(m => {
				this.setState({ child: m.default || m });
			});
		};

		this.shouldComponentUpdate = (_, nxt) => {
			nxt = nxt.child === void 0;
			if (nxt && old === void 0 && b) {
				old = b.nodeType===3 ? b.data : h(b.nodeName, { dangerouslySetInnerHTML: { __html: b.innerHTML } });
			} else {
				old = ''; // dump it
			}
			return !nxt;
		};

		this.render = (p, s) => s.child ? h(s.child, p) : old;
	}
{'fraction_non_alphanumeric': 0.18454935622317598, 'fraction_numerical': 0.00715307582260372, 'mean_word_length': 2.7913279132791327, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '6702423', 'n_tokens_mistral': 585, 'n_tokens_neox': 500, 'n_words': 128}