Sha256: 6d06fc8fcdbc5b4af57bd57a93c47f2963e3ebd1a94bbb546bf22a4de934135c

Contents?: true

Size: 1.29 KB

Versions: 3

Compression:

Stored size: 1.29 KB

Contents

"use strict";

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

const closest = require("../helpers/traversal").closest;
const createDOMTokenList = require("../dom-token-list").create;
const resetDOMTokenList = require("../dom-token-list").reset;

class HTMLTableCellImpl extends HTMLElementImpl {
  get headers() {
    if (this._headers === undefined) {
      this._headers = createDOMTokenList(this, "headers");
    }
    return this._headers;
  }

  get cellIndex() {
    const tr = closest(this, "tr");
    if (tr === null) {
      return -1;
    }

    return Array.prototype.indexOf.call(tr.cells, idlUtils.wrapperForImpl(this));
  }

  get colSpan() {
    const value = this.getAttribute("colspan");
    return value === null ? 1 : value;
  }

  set colSpan(V) {
    this.setAttribute("colspan", String(V));
  }

  get rowSpan() {
    const value = this.getAttribute("rowspan");
    return value === null ? 1 : value;
  }

  set rowSpan(V) {
    this.setAttribute("rowspan", String(V));
  }

  _attrModified(name, value, oldValue) {
    if (name === "headers" && this._headers) {
      resetDOMTokenList(this._headers, value);
    }

    super._attrModified(name, value, oldValue);
  }
}

module.exports = {
  implementation: HTMLTableCellImpl
};

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/HTMLTableCellElement-impl.js
lanes-0.8.0 node_modules/jsdom/lib/jsdom/living/nodes/HTMLTableCellElement-impl.js
select_all-rails-0.3.1 node_modules/jsdom/lib/jsdom/living/nodes/HTMLTableCellElement-impl.js