<commit_before>"use strict";

var m      = require("mithril"),
    assign = require("lodash.assign"),

    css = require("./select.css");

module.exports = require("./lib/multiple")({
        multiple : false
    },

    function(ctrl, options) {
        var field = options.field;

        return m("select", assign({
                // attrs
                class : css.select,

                // events
                onchange : function(e) {
                    var tgt = e.target,
                        opt = field.children[tgt.selectedIndex];

                    ctrl.value(options, opt.key, opt.value);
                }
            }, field.attrs),
            field.children.map(function(option) {
                return m("option", assign({}, option.attrs, { value : option.value }),
                    option.name
                );
            })
        );
    }
);
<commit_msg>Select type option should be selected if set.<commit_after>"use strict";

var m      = require("mithril"),
    assign = require("lodash.assign"),

    css = require("./select.css");

module.exports = require("./lib/multiple")({
        multiple : false
    },

    function(ctrl, options) {
        var field = options.field;

        return m("select", assign({
                // attrs
                class : css.select,

                // events
                onchange : function(e) {
                    var tgt = e.target,
                        opt = field.children[tgt.selectedIndex];

                    ctrl.value(options, opt.key, opt.value);
                }
            }, field.attrs),
            field.children.map(function(option) {
                return m("option", assign({}, option.attrs, {
                        value : option.value,
                        selected : option.selected ? "selected" : null
                    }),
                    option.name
                );
            })
        );
    }
);

{'fraction_non_alphanumeric': 0.12873326467559218, 'fraction_numerical': 0.0, 'mean_word_length': 1.23590333716916, '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': '6301973', 'n_tokens_mistral': 511, 'n_tokens_neox': 476, 'n_words': 99}