<commit_before>var doc = require('doc-js');

module.exports = function(hoverClass, selector){
    var down = [],
        selector = selector || 'button, a',
        hoverClass = hoverClass || 'hover';

    doc(document).on('touchstart mousedown', selector, function(event){
        var target = doc(event.target).closest(selector);
        doc(target).addClass(hoverClass);
        down.push(target);
    });
    doc(document).on('touchend mouseup', function(event){
        while(down.length){
            doc(down.pop()).removeClass(hoverClass);
        }
    });
};<commit_msg>improved class removal to happen on mousemove, touchcancel<commit_after>var doc = require('doc-js');

module.exports = function(hoverClass, selector){
    var down = [],
        selector = selector || 'button, a',
        hoverClass = hoverClass || 'hover';

    doc(document).on('touchstart mousedown', selector, function(event){
        var target = doc(event.target).closest(selector);
        doc(target).addClass(hoverClass);
        down.push(target);
    });
    doc(document).on('touchend touchcancel mouseup mousemove', function(event){
        while(down.length){
            doc(down.pop()).removeClass(hoverClass);
        }
    });
};
{'fraction_non_alphanumeric': 0.15403422982885084, 'fraction_numerical': 0.0, 'mean_word_length': 3.17687074829932, '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': '4053018', 'n_tokens_mistral': 349, 'n_tokens_neox': 345, 'n_words': 67}