HEX
Server: Apache/2.4.41 (Ubuntu)
System: Linux wordpress-ubuntu-s-2vcpu-4gb-fra1-01 5.4.0-169-generic #187-Ubuntu SMP Thu Nov 23 14:52:28 UTC 2023 x86_64
User: root (0)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/lipovac/wp-content/plugins/the-events-calendar/common/src/modules/utils/dom.js
/**
 * External dependencies
 */
import { noop } from 'lodash';

/**
 * Test if a node element has a class present on it
 *
 * @param {HTMLElement|Element} node The node where to look for the class names
 * @param {array} classNames List of class names as an array of strings
 * @returns {boolean} `true` if has any of the classes or false if does not have any
 */
export const hasClass = ( node, classNames = [] ) => {
	for ( let i = 0; i < classNames.length; i++ ) {
		if ( node.classList.contains( classNames[ i ] ) ) {
			return true;
		}
	}
	return false;
};

/**
 * Utility to search the parent of a node looking from the current node Up to the highest
 * node on the DOM Tree
 *
 * @param {(DOMElement|object)} node - The DOM node where the search starts
 * @param {function} callback - Is executed on every iteration, it should return a boolean
 * @returns {boolean} Returns tre if the callback returns true with any of the parents.
 */
export const searchParent = ( node = {}, callback = noop ) => {
	let found = false;
	let testNode = node;
	do {
		if ( testNode ) {
			found = callback( testNode );
		}
		const nextNode = testNode && testNode.parentNode ? testNode.parentNode : null;
		testNode = isRootNode( nextNode ) ? null : nextNode;
	} while ( ! found && testNode !== null );

	return found;
};

/**
 * Test if a node is the same as the root element or the base node of the document.
 *
 * @param {Element} node A Document Node
 * @returns {boolean} true if node is the root Node Document
 */
export const isRootNode = ( node ) => node === window.top.document;