function coerce(val) {
  if (val instanceof Error) return val.stack || val.message;
  return val;
}
Sets a specified attribute listener to a given EventTarget object.

@param {EventTarget} eventTarget - An EventTarget object to set.
@param {string} type - An event type to set.
@param {function|null} listener - A listener to be set.
@returns {void}