<commit_before>(function() {
    var arrayOf = function(pseudoArray) {
            return Array.prototype.slice.call(pseudoArray);
        },

        fire = function (node, type, _detail_) {
            var detail = _detail_ === null || _detail_ === undefined ? {} : _detail_,
                event = new CustomEvent(type, {
                    bubbles: true,
                    cancelable: true,
                    detail: detail
                });

            // hack to ensure preventDefault() in IE10+ actually sets the defaultPrevented property
            if (customPreventDefaultIgnored) {
                event.preventDefault = function () {
                    Object.defineProperty(this, 'defaultPrevented', {
                        get: function () {
                            return true;
                        }
                    });
                };
            }

            node.dispatchEvent(event);
            return event;
        },

        customPreventDefaultIgnored = (function () {
            var tempElement = document.createElement('div'),
                event = fire(tempElement, 'foobar');

            event.preventDefault();
            return !event.defaultPrevented;
        }()),

        getEnctype = function(ajaxForm) {
            var enctype = ajaxForm.getAttribute('enctype');

            return enctype || 'application/x-www-form-urlencoded';
        },

        getValidMethod = function(method) {
            if (method) {
                var proposedMethod = method.toUpperCase();

                if (['GET', 'POST', 'PUT', 'PATCH'].indexOf(proposedMethod) >= 0) {
                    return proposedMethod;
                }
            }
        },

        // Note that _currentScript is a polyfill-specific convention
        importDoc = document._currentScript.ownerDocument,

        // NOTE: Safari doesn't have any visual indications when submit is blocked
        interceptSubmit = function(ajaxForm) {
            // Intercept submit event
            ajaxForm.addEventListener('submit', function(event) {
                // Stop form submission.  Believe it or not,
                // both of these are required for some reason,
                // and returning false doesn't seem to reliably work.
                event.preventDefault();
                event.stopPropagation();

                // respect any field validation attributes
                if (ajaxForm.checkValidity()) {
                    sendFormData(ajaxForm);
                }
            });

            // Intercept native form submit function.
            // In order to force the browser to highlight the invalid fields,
            // we need to create a hidden submit button and click it if the form is invalid.
            var fakeSubmitEl = document.createElement('input');
            fakeSubmitEl.setAttribute('type', 'submit');
            fakeSubmitEl.style.display = 'none';
            ajaxForm.appendChild(fakeSubmitEl);
            ajaxForm.submit = function() {
                ajaxForm._preventValidityCheck = false;
                if (ajaxForm.checkValidity()) {
                    fire(ajaxForm, 'submit');
                }
                else {
                    ajaxForm._preventValidityCheck = true;
                    fakeSubmitEl.click();
                }
            };
        },

        isCheckboxOrRadioButton = function(element) {
            var elementType = element.type,
                role = element.getAttribute('role');

            return elementType === 'checkbox' ||
                role === 'checkbox' ||
                elementType === 'radio' ||
                role === 'radio';
        },

        maybeParseCoreDropdownMenu = function(customElement, data) {
            if (customElement.tagName.toLowerCase() === 'core-dropdown-menu' ||
                customElement.tagName.toLowerCase() === 'paper-dropdown-menu') {
                var coreMenu = customElement.querySelector('core-menu'),
                    selectedItem = coreMenu && coreMenu.selectedItem;

                if (selectedItem) {
                    processFormValue(customElement.getAttribute('name'), selectedItem.label || selectedItem.textContent, data);
                }

                return true;
            }
        },

        maybeParseCustomElementOrFileInput = function(spec) {
            if (spec.customElement.tagName.indexOf('-') >= 0 ) {
                var name = spec.customElement.getAttribute('name');

                if (isCheckboxOrRadioButton(spec.customElement)) {
                    var radioValue = parseRadioElementValue(spec.customElement);
                    if (radioValue) {
                        processFormValue(name, radioValue, spec.data);
                        return true;
                    }
                }
                else if (spec.customElement.files) {
                    if (spec.parseFileInputs) {
                        processFormValue(name, arrayOf(spec.customElement.files), spec.data);
                        spec.form._fileInputFieldNames.push(name);
                    }
                    return true;
                }
                else {
                    processFormValue(name, spec.customElement.value, spec.data);
                    return true;
                }
            }
        },

        parseCustomElements = function(form, parseFileInputs) {
            var data = {};

            form._fileInputFieldNames = [];

            arrayOf(form.querySelectorAll('*[name]')).forEach(function(el) {
                maybeParseCoreDropdownMenu(el, data) ||
                maybeParseCustomElementOrFileInput({
                    customElement: el,
                    data: data,
                    form: form,
                    parseFileInputs: parseFileInputs
                });
            });

            return data;
        },
<commit_msg>fix(file-input): input type=file elements are ignored too #65<commit_after>(function() {
    var arrayOf = function(pseudoArray) {
            return Array.prototype.slice.call(pseudoArray);
        },

        fire = function (node, type, _detail_) {
            var detail = _detail_ === null || _detail_ === undefined ? {} : _detail_,
                event = new CustomEvent(type, {
                    bubbles: true,
                    cancelable: true,
                    detail: detail
                });

            // hack to ensure preventDefault() in IE10+ actually sets the defaultPrevented property
            if (customPreventDefaultIgnored) {
                event.preventDefault = function () {
                    Object.defineProperty(this, 'defaultPrevented', {
                        get: function () {
                            return true;
                        }
                    });
                };
            }

            node.dispatchEvent(event);
            return event;
        },

        customPreventDefaultIgnored = (function () {
            var tempElement = document.createElement('div'),
                event = fire(tempElement, 'foobar');

            event.preventDefault();
            return !event.defaultPrevented;
        }()),

        getEnctype = function(ajaxForm) {
            var enctype = ajaxForm.getAttribute('enctype');

            return enctype || 'application/x-www-form-urlencoded';
        },

        getValidMethod = function(method) {
            if (method) {
                var proposedMethod = method.toUpperCase();

                if (['GET', 'POST', 'PUT', 'PATCH'].indexOf(proposedMethod) >= 0) {
                    return proposedMethod;
                }
            }
        },

        // Note that _currentScript is a polyfill-specific convention
        importDoc = document._currentScript.ownerDocument,

        // NOTE: Safari doesn't have any visual indications when submit is blocked
        interceptSubmit = function(ajaxForm) {
            // Intercept submit event
            ajaxForm.addEventListener('submit', function(event) {
                // Stop form submission.  Believe it or not,
                // both of these are required for some reason,
                // and returning false doesn't seem to reliably work.
                event.preventDefault();
                event.stopPropagation();

                // respect any field validation attributes
                if (ajaxForm.checkValidity()) {
                    sendFormData(ajaxForm);
                }
            });

            // Intercept native form submit function.
            // In order to force the browser to highlight the invalid fields,
            // we need to create a hidden submit button and click it if the form is invalid.
            var fakeSubmitEl = document.createElement('input');
            fakeSubmitEl.setAttribute('type', 'submit');
            fakeSubmitEl.style.display = 'none';
            ajaxForm.appendChild(fakeSubmitEl);
            ajaxForm.submit = function() {
                ajaxForm._preventValidityCheck = false;
                if (ajaxForm.checkValidity()) {
                    fire(ajaxForm, 'submit');
                }
                else {
                    ajaxForm._preventValidityCheck = true;
                    fakeSubmitEl.click();
                }
            };
        },

        isCheckboxOrRadioButton = function(element) {
            var elementType = element.type,
                role = element.getAttribute('role');

            return elementType === 'checkbox' ||
                role === 'checkbox' ||
                elementType === 'radio' ||
                role === 'radio';
        },

        maybeParseCoreDropdownMenu = function(customElement, data) {
            if (customElement.tagName.toLowerCase() === 'core-dropdown-menu' ||
                customElement.tagName.toLowerCase() === 'paper-dropdown-menu') {
                var coreMenu = customElement.querySelector('core-menu'),
                    selectedItem = coreMenu && coreMenu.selectedItem;

                if (selectedItem) {
                    processFormValue(customElement.getAttribute('name'), selectedItem.label || selectedItem.textContent, data);
                }

                return true;
            }
        },

        maybeParseCustomElementOrFileInput = function(spec) {
            var name = spec.customElement.getAttribute('name');
            spec.name = name;

            if (spec.customElement.tagName.indexOf('-') >= 0 ) {
                if (isCheckboxOrRadioButton(spec.customElement)) {
                    var radioValue = parseRadioElementValue(spec.customElement);
                    if (radioValue) {
                        processFormValue(name, radioValue, spec.data);
                        return true;
                    }
                }
                else if (spec.customElement.files) {
                    maybeParseFileInput(spec);
                    return true;
                }
                else if (!spec.customElement.files) {
                    processFormValue(name, spec.customElement.value, spec.data);
                    return true;
                }
            }
            else if (spec.customElement.files) {
                maybeParseFileInput(spec);
                return true;
            }
        },

        maybeParseFileInput = function(spec) {
            if (spec.parseFileInputs) {
                processFormValue(spec.name, arrayOf(spec.customElement.files), spec.data);
                spec.form._fileInputFieldNames.push(spec.name);
            }
        },

        parseCustomElements = function(form, parseFileInputs) {
            var data = {};

            form._fileInputFieldNames = [];

            arrayOf(form.querySelectorAll('*[name]')).forEach(function(el) {
                maybeParseCoreDropdownMenu(el, data) ||
                maybeParseCustomElementOrFileInput({
                    customElement: el,
                    data: data,
                    form: form,
                    parseFileInputs: parseFileInputs
                });
            });

            return data;
        },

{'fraction_non_alphanumeric': 0.09517933530766699, 'fraction_numerical': 0.0008226390259953932, 'mean_word_length': 1.4140190627482128, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '2913155', 'n_tokens_mistral': 2877, 'n_tokens_neox': 2690, 'n_words': 604}