jsdom
Version:
A JavaScript implementation of many web standards
562 lines (467 loc) • 19.1 kB
JavaScript
;
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const HTMLConstructor_jsdom_living_helpers_html_constructor =
require("../../jsdom/living/helpers/html-constructor.js").HTMLConstructor;
const parseNonNegativeInteger_jsdom_living_helpers_strings =
require("../../jsdom/living/helpers/strings.js").parseNonNegativeInteger;
const ceReactionsPreSteps_jsdom_living_helpers_custom_elements =
require("../../jsdom/living/helpers/custom-elements.js").ceReactionsPreSteps;
const ceReactionsPostSteps_jsdom_living_helpers_custom_elements =
require("../../jsdom/living/helpers/custom-elements.js").ceReactionsPostSteps;
const ctorRegistrySymbol = utils.ctorRegistrySymbol;
const HTMLElement = require("./HTMLElement.js");
const interfaceName = "HTMLTableCellElement";
const $interfaceDescriptor = utils.createInterfaceDescriptor(() => HTMLElement.interfaceDescriptor);
exports.interfaceDescriptor = $interfaceDescriptor;
function $requireImpl(wrapper, globalObject, context) {
return utils.requireImplForWrapper(wrapper, $interfaceDescriptor, globalObject, interfaceName, context);
}
exports.is = value => {
return utils.implForWrapperWithInterface(value, $interfaceDescriptor) !== null;
};
exports.isImpl = value => {
return utils.isObject(value) && value instanceof Impl.implementation;
};
exports.convert = (globalObject, value, { context = "The provided value" } = {}) => {
const impl = utils.implForWrapperWithInterface(value, $interfaceDescriptor);
if (impl !== null) {
return impl;
}
throw new globalObject.TypeError(`${context} is not of type 'HTMLTableCellElement'.`);
};
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["HTMLTableCellElement"].prototype;
}
return Object.create(proto);
}
exports.create = (globalObject, constructorArgs, privateData) => {
const wrapper = makeWrapper(globalObject);
return exports.setup(wrapper, globalObject, constructorArgs, privateData);
};
exports.createImpl = (globalObject, constructorArgs, privateData) => {
const wrapper = exports.create(globalObject, constructorArgs, privateData);
return utils.implForWrapper(wrapper);
};
exports._internalSetup = (wrapper, globalObject) => {
HTMLElement._internalSetup(wrapper, globalObject);
};
exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => {
privateData.wrapper = wrapper;
exports._internalSetup(wrapper, globalObject);
const impl = new Impl.implementation(globalObject, constructorArgs, privateData);
utils.registerWrapper(wrapper, impl, $interfaceDescriptor);
impl[utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(impl);
}
return wrapper;
};
exports.new = (globalObject, newTarget) => {
const wrapper = makeWrapper(globalObject, newTarget);
exports._internalSetup(wrapper, globalObject);
const impl = Object.create(Impl.implementation.prototype);
utils.registerWrapper(wrapper, impl, $interfaceDescriptor);
impl[utils.wrapperSymbol] = wrapper;
if (Impl.init) {
Impl.init(impl);
}
return impl;
};
const exposed = new Set(["Window"]);
exports.install = (globalObject, globalNames) => {
if (!globalNames.some(globalName => exposed.has(globalName))) {
return;
}
const ctorRegistry = utils.initCtorRegistry(globalObject);
class HTMLTableCellElement extends globalObject.HTMLElement {
constructor() {
return HTMLConstructor_jsdom_living_helpers_html_constructor(globalObject, interfaceName, new.target);
}
get colSpan() {
const $impl = $requireImpl(this ?? globalObject, globalObject, "get colSpan");
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
let value = $impl._reflectGetTheContentAttribute("colspan");
if (value !== null) {
value = parseNonNegativeInteger_jsdom_living_helpers_strings(value);
if (value !== null) {
if (value < 1) {
return 1;
} else if (value >= 1 && value <= 1000) {
return value;
} else {
return 1000;
}
}
}
return 1;
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
set colSpan(V) {
const $impl = $requireImpl(this ?? globalObject, globalObject, "set colSpan");
V = conversions["unsigned long"](V, {
context: "Failed to set the 'colSpan' property on 'HTMLTableCellElement': The provided value",
globals: globalObject
});
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
const newValue = V <= 2147483647 && V >= 0 ? V : 1;
$impl._reflectSetTheContentAttribute("colspan", String(newValue));
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
get rowSpan() {
const $impl = $requireImpl(this ?? globalObject, globalObject, "get rowSpan");
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
let value = $impl._reflectGetTheContentAttribute("rowspan");
if (value !== null) {
value = parseNonNegativeInteger_jsdom_living_helpers_strings(value);
if (value !== null) {
if (value < 0) {
return 0;
} else if (value >= 0 && value <= 65534) {
return value;
} else {
return 65534;
}
}
}
return 1;
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
set rowSpan(V) {
const $impl = $requireImpl(this ?? globalObject, globalObject, "set rowSpan");
V = conversions["unsigned long"](V, {
context: "Failed to set the 'rowSpan' property on 'HTMLTableCellElement': The provided value",
globals: globalObject
});
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
const newValue = V <= 2147483647 && V >= 0 ? V : 1;
$impl._reflectSetTheContentAttribute("rowspan", String(newValue));
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
get headers() {
const $impl = $requireImpl(this ?? globalObject, globalObject, "get headers");
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
const value = $impl._reflectGetTheContentAttribute("headers");
return value === null ? "" : value;
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
set headers(V) {
const $impl = $requireImpl(this ?? globalObject, globalObject, "set headers");
V = conversions["DOMString"](V, {
context: "Failed to set the 'headers' property on 'HTMLTableCellElement': The provided value",
globals: globalObject
});
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
$impl._reflectSetTheContentAttribute("headers", V);
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
get cellIndex() {
const $impl = $requireImpl(this ?? globalObject, globalObject, "get cellIndex");
return $impl["cellIndex"];
}
get scope() {
const $impl = $requireImpl(this ?? globalObject, globalObject, "get scope");
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
return $impl["scope"];
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
set scope(V) {
const $impl = $requireImpl(this ?? globalObject, globalObject, "set scope");
V = conversions["DOMString"](V, {
context: "Failed to set the 'scope' property on 'HTMLTableCellElement': The provided value",
globals: globalObject
});
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
$impl["scope"] = V;
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
get abbr() {
const $impl = $requireImpl(this ?? globalObject, globalObject, "get abbr");
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
const value = $impl._reflectGetTheContentAttribute("abbr");
return value === null ? "" : value;
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
set abbr(V) {
const $impl = $requireImpl(this ?? globalObject, globalObject, "set abbr");
V = conversions["DOMString"](V, {
context: "Failed to set the 'abbr' property on 'HTMLTableCellElement': The provided value",
globals: globalObject
});
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
$impl._reflectSetTheContentAttribute("abbr", V);
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
get align() {
const $impl = $requireImpl(this ?? globalObject, globalObject, "get align");
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
const value = $impl._reflectGetTheContentAttribute("align");
return value === null ? "" : value;
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
set align(V) {
const $impl = $requireImpl(this ?? globalObject, globalObject, "set align");
V = conversions["DOMString"](V, {
context: "Failed to set the 'align' property on 'HTMLTableCellElement': The provided value",
globals: globalObject
});
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
$impl._reflectSetTheContentAttribute("align", V);
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
get axis() {
const $impl = $requireImpl(this ?? globalObject, globalObject, "get axis");
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
const value = $impl._reflectGetTheContentAttribute("axis");
return value === null ? "" : value;
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
set axis(V) {
const $impl = $requireImpl(this ?? globalObject, globalObject, "set axis");
V = conversions["DOMString"](V, {
context: "Failed to set the 'axis' property on 'HTMLTableCellElement': The provided value",
globals: globalObject
});
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
$impl._reflectSetTheContentAttribute("axis", V);
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
get height() {
const $impl = $requireImpl(this ?? globalObject, globalObject, "get height");
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
const value = $impl._reflectGetTheContentAttribute("height");
return value === null ? "" : value;
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
set height(V) {
const $impl = $requireImpl(this ?? globalObject, globalObject, "set height");
V = conversions["DOMString"](V, {
context: "Failed to set the 'height' property on 'HTMLTableCellElement': The provided value",
globals: globalObject
});
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
$impl._reflectSetTheContentAttribute("height", V);
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
get width() {
const $impl = $requireImpl(this ?? globalObject, globalObject, "get width");
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
const value = $impl._reflectGetTheContentAttribute("width");
return value === null ? "" : value;
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
set width(V) {
const $impl = $requireImpl(this ?? globalObject, globalObject, "set width");
V = conversions["DOMString"](V, {
context: "Failed to set the 'width' property on 'HTMLTableCellElement': The provided value",
globals: globalObject
});
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
$impl._reflectSetTheContentAttribute("width", V);
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
get ch() {
const $impl = $requireImpl(this ?? globalObject, globalObject, "get ch");
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
const value = $impl._reflectGetTheContentAttribute("char");
return value === null ? "" : value;
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
set ch(V) {
const $impl = $requireImpl(this ?? globalObject, globalObject, "set ch");
V = conversions["DOMString"](V, {
context: "Failed to set the 'ch' property on 'HTMLTableCellElement': The provided value",
globals: globalObject
});
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
$impl._reflectSetTheContentAttribute("char", V);
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
get chOff() {
const $impl = $requireImpl(this ?? globalObject, globalObject, "get chOff");
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
const value = $impl._reflectGetTheContentAttribute("charoff");
return value === null ? "" : value;
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
set chOff(V) {
const $impl = $requireImpl(this ?? globalObject, globalObject, "set chOff");
V = conversions["DOMString"](V, {
context: "Failed to set the 'chOff' property on 'HTMLTableCellElement': The provided value",
globals: globalObject
});
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
$impl._reflectSetTheContentAttribute("charoff", V);
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
get noWrap() {
const $impl = $requireImpl(this ?? globalObject, globalObject, "get noWrap");
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
return $impl._reflectGetTheContentAttribute("nowrap") !== null;
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
set noWrap(V) {
const $impl = $requireImpl(this ?? globalObject, globalObject, "set noWrap");
V = conversions["boolean"](V, {
context: "Failed to set the 'noWrap' property on 'HTMLTableCellElement': The provided value",
globals: globalObject
});
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
if (V) {
$impl._reflectSetTheContentAttribute("nowrap", "");
} else {
$impl._reflectDeleteTheContentAttribute("nowrap");
}
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
get vAlign() {
const $impl = $requireImpl(this ?? globalObject, globalObject, "get vAlign");
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
const value = $impl._reflectGetTheContentAttribute("valign");
return value === null ? "" : value;
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
set vAlign(V) {
const $impl = $requireImpl(this ?? globalObject, globalObject, "set vAlign");
V = conversions["DOMString"](V, {
context: "Failed to set the 'vAlign' property on 'HTMLTableCellElement': The provided value",
globals: globalObject
});
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
$impl._reflectSetTheContentAttribute("valign", V);
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
get bgColor() {
const $impl = $requireImpl(this ?? globalObject, globalObject, "get bgColor");
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
const value = $impl._reflectGetTheContentAttribute("bgcolor");
return value === null ? "" : value;
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
set bgColor(V) {
const $impl = $requireImpl(this ?? globalObject, globalObject, "set bgColor");
V = conversions["DOMString"](V, {
context: "Failed to set the 'bgColor' property on 'HTMLTableCellElement': The provided value",
globals: globalObject,
treatNullAsEmptyString: true
});
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
$impl._reflectSetTheContentAttribute("bgcolor", V);
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
}
Object.defineProperties(HTMLTableCellElement.prototype, {
colSpan: { enumerable: true },
rowSpan: { enumerable: true },
headers: { enumerable: true },
cellIndex: { enumerable: true },
scope: { enumerable: true },
abbr: { enumerable: true },
align: { enumerable: true },
axis: { enumerable: true },
height: { enumerable: true },
width: { enumerable: true },
ch: { enumerable: true },
chOff: { enumerable: true },
noWrap: { enumerable: true },
vAlign: { enumerable: true },
bgColor: { enumerable: true },
[Symbol.toStringTag]: { value: "HTMLTableCellElement", configurable: true }
});
ctorRegistry[interfaceName] = HTMLTableCellElement;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,
writable: true,
value: HTMLTableCellElement
});
};
const Impl = require("../../jsdom/living/nodes/HTMLTableCellElement-impl.js");