Sha256: fe393880f88a6894ffcd792b09c9c22e0e497c007ee00e6987a7483ed1874d4a

Contents?: true

Size: 1.62 KB

Versions: 46

Compression:

Stored size: 1.62 KB

Contents

"use strict";

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

const { asciiLowercase, parseNonNegativeInteger } = require("../helpers/strings");
const { closest } = require("../helpers/traversal");

function reflectedAttributeClampedToRange(attrValue, min, max, defaultValue = 0) {
  if (attrValue === null) {
    return defaultValue;
  }
  const parsed = parseNonNegativeInteger(attrValue);
  if (parsed === null) {
    return defaultValue;
  }
  if (parsed < min) {
    return min;
  }
  if (parsed > max) {
    return max;
  }
  return parsed;
}

class HTMLTableCellElementImpl extends HTMLElementImpl {
  get colSpan() {
    return reflectedAttributeClampedToRange(this.getAttributeNS(null, "colspan"), 1, 1000, 1);
  }

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

  get rowSpan() {
    return reflectedAttributeClampedToRange(this.getAttributeNS(null, "rowspan"), 0, 65534, 1);
  }

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

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

    return tr.cells.indexOf(this);
  }

  get scope() {
    let value = this.getAttributeNS(null, "scope");
    if (value === null) {
      return "";
    }

    // Enumerated attribute is matched ASCII-case-insensitively.
    value = asciiLowercase(value);
    if (value === "row" || value === "col" || value === "rowgroup" || value === "colgroup") {
      return value;
    }

    return "";
  }

  set scope(V) {
    this.setAttributeNS(null, "scope", V);
  }
}

module.exports = {
  implementation: HTMLTableCellElementImpl
};

Version data entries

46 entries across 46 versions & 2 rubygems

Version Path
clapton-0.0.26 lib/clapton/javascripts/node_modules/jsdom/lib/jsdom/living/nodes/HTMLTableCellElement-impl.js
clapton-0.0.25 lib/clapton/javascripts/node_modules/jsdom/lib/jsdom/living/nodes/HTMLTableCellElement-impl.js
clapton-0.0.24 lib/clapton/javascripts/node_modules/jsdom/lib/jsdom/living/nodes/HTMLTableCellElement-impl.js
clapton-0.0.23 lib/clapton/javascripts/node_modules/jsdom/lib/jsdom/living/nodes/HTMLTableCellElement-impl.js
clapton-0.0.22 lib/clapton/javascripts/node_modules/jsdom/lib/jsdom/living/nodes/HTMLTableCellElement-impl.js
clapton-0.0.21 lib/clapton/javascripts/node_modules/jsdom/lib/jsdom/living/nodes/HTMLTableCellElement-impl.js
clapton-0.0.20 lib/clapton/javascripts/node_modules/jsdom/lib/jsdom/living/nodes/HTMLTableCellElement-impl.js
clapton-0.0.19 lib/clapton/javascripts/node_modules/jsdom/lib/jsdom/living/nodes/HTMLTableCellElement-impl.js
clapton-0.0.18 lib/clapton/javascripts/node_modules/jsdom/lib/jsdom/living/nodes/HTMLTableCellElement-impl.js
clapton-0.0.17 lib/clapton/javascripts/node_modules/jsdom/lib/jsdom/living/nodes/HTMLTableCellElement-impl.js
clapton-0.0.16 lib/clapton/javascripts/node_modules/jsdom/lib/jsdom/living/nodes/HTMLTableCellElement-impl.js
clapton-0.0.15 lib/clapton/javascripts/node_modules/jsdom/lib/jsdom/living/nodes/HTMLTableCellElement-impl.js
clapton-0.0.14 lib/clapton/javascripts/node_modules/jsdom/lib/jsdom/living/nodes/HTMLTableCellElement-impl.js
clapton-0.0.13 lib/clapton/javascripts/node_modules/jsdom/lib/jsdom/living/nodes/HTMLTableCellElement-impl.js
clapton-0.0.12 lib/clapton/javascripts/node_modules/jsdom/lib/jsdom/living/nodes/HTMLTableCellElement-impl.js
clapton-0.0.11 lib/clapton/javascripts/node_modules/jsdom/lib/jsdom/living/nodes/HTMLTableCellElement-impl.js
clapton-0.0.10 lib/clapton/javascripts/node_modules/jsdom/lib/jsdom/living/nodes/HTMLTableCellElement-impl.js
clapton-0.0.9 lib/clapton/javascripts/node_modules/jsdom/lib/jsdom/living/nodes/HTMLTableCellElement-impl.js
clapton-0.0.8 lib/clapton/javascripts/node_modules/jsdom/lib/jsdom/living/nodes/HTMLTableCellElement-impl.js
clapton-0.0.7 lib/clapton/javascripts/node_modules/jsdom/lib/jsdom/living/nodes/HTMLTableCellElement-impl.js