Sha256: 1c140eb1f72e3de824c59d3cdd3a878e290fc269bdbefb0b76fe7c7b15e3f9c1

Contents?: true

Size: 1.1 KB

Versions: 1

Compression:

Stored size: 1.1 KB

Contents

(function (prototype) {
  if (typeof prototype.requestSubmit == "function") return;

  prototype.requestSubmit = function (submitter) {
    if (submitter) {
      validateSubmitter(submitter, this);
      submitter.click();
    } else {
      submitter = document.createElement("input");
      submitter.type = "submit";
      submitter.hidden = true;
      this.appendChild(submitter);
      submitter.click();
      this.removeChild(submitter);
    }
  };

  function validateSubmitter(submitter, form) {
    submitter instanceof HTMLElement ||
      raise(TypeError, "parameter 1 is not of type 'HTMLElement'");
    submitter.type == "submit" ||
      raise(TypeError, "The specified element is not a submit button");
    submitter.form == form ||
      raise(
        DOMException,
        "The specified element is not owned by this form element",
        "NotFoundError"
      );
  }

  function raise(errorConstructor, message, name) {
    throw new errorConstructor(
      "Failed to execute 'requestSubmit' on 'HTMLFormElement': " +
        message +
        ".",
      name
    );
  }
})(HTMLFormElement.prototype);

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
coveragebook_components-0.5.2 app/assets/js/base/polyfills/request-submit.js