<commit_before>/**
 * Patterns checkedflag - Add checked flag to checkbox labels
 *
 * Copyright 2013 Simplon B.V. - <NAME>
 * Copyright 2013 <NAME>
 */
define([
    "jquery",
    "../registry",
    "../utils"
], function($, patterns, utils) {
    var select_option = {
        name: "select-option",
        trigger: "label select",

        init: function($el) {
            $el.on("change.pat-select-option", select_option._onChange);
            select_option._onChange.call(this);
            return $el;
        },

        destroy: function($el) {
            return $el.off(".pat-select-option");
        },

        _onChange: function() {
            var label = utils.findLabel(this);
            if (label !== null) {
                $(label).attr('data-option', $(this).val() || "");
            }
        }
    };

    patterns.register(select_option);
    return select_option;
});<commit_msg>create span parent if select has no label parent<commit_after>/**
 * Patterns checkedflag - Add checked flag to checkbox labels
 *
 * Copyright 2013 Simplon B.V. - <NAME>
 * Copyright 2013 <NAME>
 */
define([
    "jquery",
    "../registry"
], function($, patterns) {
    var select_option = {
        name: "select-option",
        trigger: "select",

        init: function($el) {
            $el.each(function() {
                var $el = $(this);
                // create parent span if not direct child of a label
                if ($el.parent('label').length === 0) {
                    $el.wrap('<span />');
                }
                $el.parent().attr('data-option', $el.val() || "");
            }).on("change.pat-select-option", function() {
                $(this).parent().attr('data-option', $el.val() || "");
            });
        },

        destroy: function($el) {
            return $el.off(".pat-select-option");
        }
    };

    patterns.register(select_option);
    return select_option;
});
{'fraction_non_alphanumeric': 0.16666666666666666, 'fraction_numerical': 0.008771929824561403, 'mean_word_length': 1.8265306122448979, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, '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': '3482043', 'n_tokens_mistral': 571, 'n_tokens_neox': 546, 'n_words': 124}