/**
* @module openNewTab
* @description Opens a passed link in a new tab. Must be used inside a method triggered by user
* input to avoid popup blockers.
*
* @since 1.0.0
*
* @param {string} url The url to open.
*
* @return {void}
*
* @example
* import { openNewTab } from "@gravityforms/utils";
*
* function Example() {
* const url = 'https://some-url.com/hello.jpg';
* openNewTab( url );
* }
*
*/
export default function openNewTab( url = '' ) {
const link = document.createElement( 'a' );
link.href = url;
link.target = '_blank';
document.body.appendChild( link );
link.click();
link.remove();
}