<commit_before>/*global delegateListener,getElementTagName */

/*
Description:
Relies on `jessie.delegateListener` amd `jessie.getElementTagName`
*/

/*
Author:
<NAME>
*/

var delegateTagNameListener;

if(delegateListener && getElementTagName) {
	delegateTagNameListener = function(el, eventType, tagName, fn) {
		
		var fnDelegate = function(el, target) {
			var sourceNode,
                descendant;

			if(getElementTagName(target) === tagName) {
				sourceNode = target;
			} else {
                descendant = target.parentNode;

                while (descendant !== el) {
                    if (getElementTagName(descendant) === tagName) {
                        sourceNode = descendant;
                        break;
                    }
                    descendant = descendant.parentNode;
                }
            }
			return sourceNode;
		};

		return delegateListener(el, eventType, fn, fnDelegate);
	};
}<commit_msg>getElementParentElement now being used rather than parentNode relevant comments and intellisense added, tabs converted to spaces<commit_after>/*global delegateListener,getElementTagName,getElementParentElement */

/*
Description:
Relies on `jessie.delegateListener` and `jessie.getElementTagName` and `jessie.getElementParentElement`
*/

/*
Author:
<NAME>
*/

var delegateTagNameListener;

if(delegateListener && getElementTagName) {
    delegateTagNameListener = function(el, eventType, tagName, fn) {

        var fnDelegate = function(el, target) {
            var sourceNode,
                descendant;

            if(getElementTagName(target) === tagName) {
                sourceNode = target;
            } else {
                descendant = getElementParentElement(target);

                if (null !== descendant) {
                    while (descendant !== el) {
                        if (getElementTagName(descendant) === tagName) {
                            sourceNode = descendant;
                            break;
                        }
                        descendant = getElementParentElement(descendant);
                    }
                }
            }
            return sourceNode;
        };

        return delegateListener(el, eventType, fn, fnDelegate);
    };
}
{'fraction_non_alphanumeric': 0.09151488227454464, 'fraction_numerical': 0.0, 'mean_word_length': 1.9361147327249022, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '3010129', 'n_tokens_mistral': 597, 'n_tokens_neox': 553, 'n_words': 122}