<commit_before>Clickable._enableStickyClick = function (trimString, isDOMNode, enableClicking) {
	var DATA_ACTIVE_CLASS = 'data-clickable-class';


	function enableStickyClick (button, activeClass, holdFunction) {
		if ( !isDOMNode(button) ) {
			throw TypeError('button must be a DOM element, got ' + button);
		}

		switch (typeof activeClass) {
			case 'string':
				break;

			case 'function':
				holdFunction = activeClass;
				activeClass  = undefined;
				break;

			default:
				throw TypeError('button active class must be a string if defined, got ' + activeClass);
		}

		if (typeof holdFunction !== 'function') {
			throw TypeError('sticky click handler must be a function, got ' + holdFunction);
		}

		enableClicking(button, activeClass);

		button.addEventListener(
			'click',
			createStickyClickHandler(button, holdFunction),
			false
		);

	}

	function createStickyClickHandler (button, holdFunction) {
		return function () {
			var lock        = false,
				activeClass = button.getAttribute(DATA_ACTIVE_CLASS),
				value;

			button.disabled = true;
			button.className += ' ' + activeClass;

			try {
				value = holdFunction(cleanUp);
			}
			catch (err) {
				if (window.console && window.console.error) {
					window.console.error(err);
					if ((typeof err === 'object') && err.stack) {
						window.console.error(err.stack);
					}
				}

				cleanUp();
			}

			if (value === false) {
				cleanUp();
			}

			function cleanUp () {
				if (lock) {
					return;
				}
				lock = true;

				if (button.disabled) {
					button.disabled = false;
					button.className = trimString(
						button.className.replace(
							new RegExp('\\b'+activeClass+'\\b', 'g'),
							''
						)
					);
				}
			}
		};
	}


	return enableStickyClick;
}(
	Clickable._trimString     , // from utils.js
	Clickable._isDOMNode      , // from utils.js
	Clickable._enableClicking   // from core.js
);
<commit_msg>better error handling for stickyclick<commit_after>Clickable._enableStickyClick = function (trimString, isDOMNode, enableClicking) {
	var DATA_ACTIVE_CLASS = 'data-clickable-class';


	function enableStickyClick (button, activeClass, holdFunction) {
		if ( !isDOMNode(button) ) {
			throw TypeError('button must be a DOM element, got ' + button);
		}

		switch (typeof activeClass) {
			case 'string':
				break;

			case 'function':
				holdFunction = activeClass;
				activeClass  = undefined;
				break;

			default:
				throw TypeError('button active class must be a string if defined, got ' + activeClass);
		}

		if (typeof holdFunction !== 'function') {
			throw TypeError('sticky click handler must be a function, got ' + holdFunction);
		}

		enableClicking(button, activeClass);

		button.addEventListener(
			'click',
			createStickyClickHandler(button, holdFunction),
			false
		);

	}

	function createStickyClickHandler (button, holdFunction) {
		return function () {
			var lock        = false,
				activeClass = button.getAttribute(DATA_ACTIVE_CLASS),
				value;

			button.disabled = true;
			button.className += ' ' + activeClass;

			try {
				value = holdFunction(cleanUp);
			}
			catch (err) {
				if (window.console && window.console.error) {
					if ((typeof err === 'object') && err.stack) {
						window.console.error(err.stack);
					}
					else {
						window.console.error(err + '');
					}
				}

				cleanUp();
			}

			if (value === false) {
				cleanUp();
			}

			function cleanUp () {
				if (lock) {
					return;
				}
				lock = true;

				if (button.disabled) {
					button.disabled = false;
					button.className = trimString(
						button.className.replace(
							new RegExp('\\b'+activeClass+'\\b', 'g'),
							''
						)
					);
				}
			}
		};
	}


	return enableStickyClick;
}(
	Clickable._trimString     , // from utils.js
	Clickable._isDOMNode      , // from utils.js
	Clickable._enableClicking   // from core.js
);

{'fraction_non_alphanumeric': 0.12554782160350605, 'fraction_numerical': 0.0, 'mean_word_length': 2.7853658536585364, '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': '3261733', 'n_tokens_mistral': 1540, 'n_tokens_neox': 1200, 'n_words': 275}