function load(image, src) {
  return new Promise((resolve, reject) => {
    function handleLoad() {
      unlisten();
      resolve(image);
    }
    function handleError() {
      unlisten();
      reject(new Error('Image load error'));
    }
    function unlisten() {
      image.removeEventListener('load', handleLoad);
      image.removeEventListener('error', handleError);
    }
    image.addEventListener('load', handleLoad);
    image.addEventListener('error', handleError);
    if (src) {
      image.src = src;
    }
  });
}
Loads an image.
@param {HTMLImageElement} image Image, not yet loaded.
@param {string} [src] `src` attribute of the image. Optional, not required if already present.
@return {Promise<HTMLImageElement>} Promise resolving to an `HTMLImageElement`.
@api