<commit_before>/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

"use strict";

import {render} from "inferno";
import {h} from "inferno-hyperscript";

export const VirtualDOMView = {

    init(container, controller) {
        this.container = container;
        this.controller = controller;
        this.state = {};

        const repaintHandler = () => this.repaint();
        controller.addListener("repaint", repaintHandler);
        window.addEventListener("resize", repaintHandler);

        while (container.firstChild) {
            container.removeChild(container.firstChild);
        }

        return this;
    },

    repaint() {
        render(this.render(), this.container, () => {
            Object.keys(this.state).forEach(key => {
                document.getElementById("field-" + key).value = this.state[key];
            });
        });
    },

    render() {
        return h("div");
    }
};<commit_msg>Fixed form update issue when toggling the preferences pane<commit_after>/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

"use strict";

import {render} from "inferno";
import {h} from "inferno-hyperscript";

export const VirtualDOMView = {

    init(container, controller) {
        this.container = container;
        this.controller = controller;
        this.state = {};

        const repaintHandler = () => this.repaint();
        controller.addListener("repaint", repaintHandler);
        window.addEventListener("resize", repaintHandler);

        while (container.firstChild) {
            container.removeChild(container.firstChild);
        }

        return this;
    },

    repaint() {
        render(this.render(), this.container, () => {
            Object.keys(this.state).forEach(key => {
                const elt = document.getElementById("field-" + key);
                if (elt) {
                    elt.value = this.state[key];
                }
            });
        });
    },

    render() {
        return h("div");
    }
};
{'fraction_non_alphanumeric': 0.12996075010902747, 'fraction_numerical': 0.0034888791975577847, 'mean_word_length': 2.2264416315049225, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '1429078', 'n_tokens_mistral': 647, 'n_tokens_neox': 612, 'n_words': 167}