jsdom
Version:
A JavaScript implementation of many web standards
287 lines (240 loc) • 9.73 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 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 = "HTMLTableSectionElement";
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 'HTMLTableSectionElement'.`);
};
function makeWrapper(globalObject, newTarget) {
let proto;
if (newTarget !== undefined) {
proto = newTarget.prototype;
}
if (!utils.isObject(proto)) {
proto = globalObject[ctorRegistrySymbol]["HTMLTableSectionElement"].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 HTMLTableSectionElement extends globalObject.HTMLElement {
constructor() {
return HTMLConstructor_jsdom_living_helpers_html_constructor(globalObject, interfaceName, new.target);
}
insertRow() {
const $impl = $requireImpl(this ?? globalObject, globalObject, "insertRow");
const args = [];
{
let curArg = arguments[0];
if (curArg !== undefined) {
curArg = conversions["long"](curArg, {
context: "Failed to execute 'insertRow' on 'HTMLTableSectionElement': parameter 1",
globals: globalObject
});
} else {
curArg = -1;
}
args.push(curArg);
}
return utils.tryWrapperForImpl($impl.insertRow(...args));
}
deleteRow(index) {
const $impl = $requireImpl(this ?? globalObject, globalObject, "deleteRow");
if (arguments.length < 1) {
throw new globalObject.TypeError(
`Failed to execute 'deleteRow' on 'HTMLTableSectionElement': 1 argument required, but only ${arguments.length} present.`
);
}
const args = [];
{
let curArg = arguments[0];
curArg = conversions["long"](curArg, {
context: "Failed to execute 'deleteRow' on 'HTMLTableSectionElement': parameter 1",
globals: globalObject
});
args.push(curArg);
}
ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
try {
return $impl.deleteRow(...args);
} finally {
ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
}
}
get rows() {
const $impl = $requireImpl(this ?? globalObject, globalObject, "get rows");
return utils.getSameObject(this, "rows", () => {
return utils.tryWrapperForImpl($impl["rows"]);
});
}
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 'HTMLTableSectionElement': 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 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 'HTMLTableSectionElement': 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 'HTMLTableSectionElement': 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 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 'HTMLTableSectionElement': 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);
}
}
}
Object.defineProperties(HTMLTableSectionElement.prototype, {
insertRow: { enumerable: true },
deleteRow: { enumerable: true },
rows: { enumerable: true },
align: { enumerable: true },
ch: { enumerable: true },
chOff: { enumerable: true },
vAlign: { enumerable: true },
[Symbol.toStringTag]: { value: "HTMLTableSectionElement", configurable: true }
});
ctorRegistry[interfaceName] = HTMLTableSectionElement;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,
writable: true,
value: HTMLTableSectionElement
});
};
const Impl = require("../../jsdom/living/nodes/HTMLTableSectionElement-impl.js");