<commit_before>import template from './';

/**
 * Detecting differences in property values and updating the DOM as necessary.
 * This function is probably the single most critical path for performance optimization.
 *
 * @param {DOMElement} element
 * @param {string} propName
 * @param {object} oldProp
 * @param {object} newProp
 */
function updateDOMProperties(element, propName, oldProp, newProp) {

    if (oldProp === newProp) {
        return;
    }

    switch (propName) {

        case 'multiple':

            // TODO! Write a unit test for this before modify!!
        case 'value':

            // unset
            if (newProp == null) {
                template.removeProperty(element, propName);
            } else {

                const lenA = oldProp.length;
                let hasDiff = false;

                if (lenA !== newProp.length) {
                    hasDiff = true;
                } else {
                    var i = 0;
                    while (!hasDiff && i < lenA) {
                        if (oldProp[i] != newProp[i]) {
                            hasDiff = true;
                        }
                        ++i;
                    }
                }

                template.setProperty(element, propName, newProp);
            }

        case 'style':
        case 'dataset':

            let styleUpdates = {};
            let styleName;

            if (oldProp != null) {
                if (newProp == null) {
                    template.removeProperty(element, propName);
                } else {
                    for (styleName in oldProp) {
                        if (oldProp[styleName] && (!newProp || !newProp[styleName])) {
                            styleUpdates[styleName] = '';
                        }
                    }
                    // Update styles that changed since `oldProp`.
                    for (styleName in newProp) {
                        if (newProp[styleName] && oldProp[styleName] !== newProp[styleName]) {
                            styleUpdates[styleName] = newProp[styleName];
                        }
                    }
                }
            } else if (newProp != null) {
                styleUpdates = newProp;
            }

            template.setProperty(element, propName, styleUpdates);

            return;
        default: // string values

            if (oldProp != null) {
                // If 'newProp' is null or undefined, we, we should remove the property
                // from the DOM node instead of inadvertantly setting to a string.
                if (newProp == null) {
                    template.removeProperty(element, propName);
                } else {
                    template.setProperty(element, propName, newProp);
                }
            } else if (newProp != null) {
                template.setProperty(element, propName, newProp);
            }
    }

}

export default updateDOMProperties;<commit_msg>removed dead code<commit_after>import template from './';

/**
 * Detecting differences in property values and updating the DOM as necessary.
 * This function is probably the single most critical path for performance optimization.
 *
 * @param {DOMElement} element
 * @param {string} propName
 * @param {object} oldProp
 * @param {object} newProp
 */
function updateDOMProperties(element, propName, oldProp, newProp) {

    if (oldProp === newProp) {
        return;
    }

    switch (propName) {
       
        case 'style':
        case 'dataset':

            let styleUpdates = {};
            let styleName;

            if (oldProp != null) {
                if (newProp == null) {
                    template.removeProperty(element, propName);
                } else {
                    for (styleName in oldProp) {
                        if (oldProp[styleName] && (!newProp || !newProp[styleName])) {
                            styleUpdates[styleName] = '';
                        }
                    }
                    // Update styles that changed since `oldProp`.
                    for (styleName in newProp) {
                        if (newProp[styleName] && oldProp[styleName] !== newProp[styleName]) {
                            styleUpdates[styleName] = newProp[styleName];
                        }
                    }
                }
            } else if (newProp != null) {
                styleUpdates = newProp;
            }

            template.setProperty(element, propName, styleUpdates);

            return;
        default: // string values

            if (oldProp != null) {
                // If 'newProp' is null or undefined, we, we should remove the property
                // from the DOM node instead of inadvertantly setting to a string.
                if (newProp == null) {
                    template.removeProperty(element, propName);
                } else {
                    template.setProperty(element, propName, newProp);
                }
            } else if (newProp != null) {
                template.setProperty(element, propName, newProp);
            }
    }

}

export default updateDOMProperties;
{'fraction_non_alphanumeric': 0.09355590062111802, 'fraction_numerical': 0.00019409937888198756, 'mean_word_length': 1.2983942908117752, 'pattern_counts': {'":': 0, '<': 4, '<?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': '4920836', 'n_tokens_mistral': 1278, 'n_tokens_neox': 1192, 'n_words': 347}