Highly efficient function to convert a nodelist into a standard array. Allows you to run Array.forEach in older browsers/safari on a Nodelist.

Parameters:
NameTypeDescription
elementsElement | NodeList | Array

to convert

Since
  • 1.0.0
Returns:

An array converted elements or empty if none passed.

Type: 
Array
Example
import { convertElements } from  "@gravityforms/utils";

function Example( convert = true ) {
 let nodes = node.querySelectorAll( '.example' );
	if ( convert ) {
		nodes = convertElements( nodes );
	}
	return nodes;
}