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:
Name | Type | Description |
---|---|---|
elements | Element | | to convert |
- Since
- 1.0.0
- Source
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;
}