Sha256: b13631419b7b39141596a187571809fd5ed014bf64a56b1691013315fdae124e

Contents?: true

Size: 1.21 KB

Versions: 3

Compression:

Stored size: 1.21 KB

Contents

"use strict";

const HTMLElementImpl = require("./HTMLElement-impl").implementation;

const closest = require("../helpers/traversal").closest;
const isDisabled = require("../helpers/form-controls").isDisabled;

class HTMLButtonElementImpl extends HTMLElementImpl {
  _activationBehavior() {
    const form = this.form;
    if (form) {
      if (this.type === "submit" && !isDisabled(this)) {
        form._dispatchSubmitEvent();
      }
    }
  }

  _getValue() {
    const valueAttr = this.getAttribute("value");
    return valueAttr === null ? "" : valueAttr;
  }

  get form() {
    return closest(this, "form");
  }

  get type() {
    const typeAttr = (this.getAttribute("type") || "").toLowerCase();
    switch (typeAttr) {
      case "submit":
      case "reset":
      case "button":
      case "menu":
        return typeAttr;
      default:
        return "submit";
    }
  }

  set type(v) {
    v = String(v).toLowerCase();
    switch (v) {
      case "submit":
      case "reset":
      case "button":
      case "menu":
        this.setAttribute("type", v);
        break;
      default:
        this.setAttribute("type", "submit");
        break;
    }
  }
}

module.exports = {
  implementation: HTMLButtonElementImpl
};

Version data entries

3 entries across 3 versions & 3 rubygems

Version Path
learn_create-0.0.22 lib/templates/javascript_lab_template/node_modules/jsdom/lib/jsdom/living/nodes/HTMLButtonElement-impl.js
lanes-0.8.0 node_modules/jsdom/lib/jsdom/living/nodes/HTMLButtonElement-impl.js
select_all-rails-0.3.1 node_modules/jsdom/lib/jsdom/living/nodes/HTMLButtonElement-impl.js