getFirstElementByClassName = (cls, root, isRequired) => {

  const el = (root || document).getElementsByClassName(cls)[0];
  if (!el && (typeof isRequired === 'boolean' ? isRequired : true)) {
    const text = `Missing element with class "${cls}" inside ${root}`;
    throw new EnvironmentError(text);
  }

  return el;

}
Works like get `getElementById()` but is based on a class name.
It will return the first element inside an optional parent (root)
that has a class of this name.

@param {string} cls - The class name to search for.
@param {Element} [root=document] - The context to search in.
@param {boolean} [isRequired=true] - If true, an exception will be
    thrown if no element can be retrieved. This is important
    when depending on third party modules and class names change!
@throws {EnvironmentError} - May be thrown if
   `isRequired` is set to true.
@return {Element} Either a dom element or null is returned.