Your IP : 216.73.216.79


Current Path : /var/www/html/learn/node_modules/@ckeditor/ckeditor5-utils/src/dom/
Upload File :
Current File : /var/www/html/learn/node_modules/@ckeditor/ckeditor5-utils/src/dom/indexof.js

/**
 * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */

/**
 * @module utils/dom/indexof
 */

/**
 * Returns index of the node in the parent element.
 *
 * @param {Node} node Node which index is tested.
 * @returns {Number} Index of the node in the parent element. Returns 0 if node has no parent.
 */
export default function indexOf( node ) {
	let index = 0;

	while ( node.previousSibling ) {
		node = node.previousSibling;
		index++;
	}

	return index;
}