HTMLTableRowElement.js 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417
  1. "use strict";
  2. const conversions = require("webidl-conversions");
  3. const utils = require("./utils.js");
  4. const HTMLConstructor_jsdom_living_helpers_html_constructor =
  5. require("../../jsdom/living/helpers/html-constructor.js").HTMLConstructor;
  6. const ceReactionsPreSteps_jsdom_living_helpers_custom_elements =
  7. require("../../jsdom/living/helpers/custom-elements.js").ceReactionsPreSteps;
  8. const ceReactionsPostSteps_jsdom_living_helpers_custom_elements =
  9. require("../../jsdom/living/helpers/custom-elements.js").ceReactionsPostSteps;
  10. const implSymbol = utils.implSymbol;
  11. const ctorRegistrySymbol = utils.ctorRegistrySymbol;
  12. const HTMLElement = require("./HTMLElement.js");
  13. const interfaceName = "HTMLTableRowElement";
  14. exports.is = value => {
  15. return utils.isObject(value) && Object.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation;
  16. };
  17. exports.isImpl = value => {
  18. return utils.isObject(value) && value instanceof Impl.implementation;
  19. };
  20. exports.convert = (globalObject, value, { context = "The provided value" } = {}) => {
  21. if (exports.is(value)) {
  22. return utils.implForWrapper(value);
  23. }
  24. throw new globalObject.TypeError(`${context} is not of type 'HTMLTableRowElement'.`);
  25. };
  26. function makeWrapper(globalObject, newTarget) {
  27. let proto;
  28. if (newTarget !== undefined) {
  29. proto = newTarget.prototype;
  30. }
  31. if (!utils.isObject(proto)) {
  32. proto = globalObject[ctorRegistrySymbol]["HTMLTableRowElement"].prototype;
  33. }
  34. return Object.create(proto);
  35. }
  36. exports.create = (globalObject, constructorArgs, privateData) => {
  37. const wrapper = makeWrapper(globalObject);
  38. return exports.setup(wrapper, globalObject, constructorArgs, privateData);
  39. };
  40. exports.createImpl = (globalObject, constructorArgs, privateData) => {
  41. const wrapper = exports.create(globalObject, constructorArgs, privateData);
  42. return utils.implForWrapper(wrapper);
  43. };
  44. exports._internalSetup = (wrapper, globalObject) => {
  45. HTMLElement._internalSetup(wrapper, globalObject);
  46. };
  47. exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => {
  48. privateData.wrapper = wrapper;
  49. exports._internalSetup(wrapper, globalObject);
  50. Object.defineProperty(wrapper, implSymbol, {
  51. value: new Impl.implementation(globalObject, constructorArgs, privateData),
  52. configurable: true
  53. });
  54. wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
  55. if (Impl.init) {
  56. Impl.init(wrapper[implSymbol]);
  57. }
  58. return wrapper;
  59. };
  60. exports.new = (globalObject, newTarget) => {
  61. const wrapper = makeWrapper(globalObject, newTarget);
  62. exports._internalSetup(wrapper, globalObject);
  63. Object.defineProperty(wrapper, implSymbol, {
  64. value: Object.create(Impl.implementation.prototype),
  65. configurable: true
  66. });
  67. wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
  68. if (Impl.init) {
  69. Impl.init(wrapper[implSymbol]);
  70. }
  71. return wrapper[implSymbol];
  72. };
  73. const exposed = new Set(["Window"]);
  74. exports.install = (globalObject, globalNames) => {
  75. if (!globalNames.some(globalName => exposed.has(globalName))) {
  76. return;
  77. }
  78. const ctorRegistry = utils.initCtorRegistry(globalObject);
  79. class HTMLTableRowElement extends globalObject.HTMLElement {
  80. constructor() {
  81. return HTMLConstructor_jsdom_living_helpers_html_constructor(globalObject, interfaceName, new.target);
  82. }
  83. insertCell() {
  84. const esValue = this !== null && this !== undefined ? this : globalObject;
  85. if (!exports.is(esValue)) {
  86. throw new globalObject.TypeError(
  87. "'insertCell' called on an object that is not a valid instance of HTMLTableRowElement."
  88. );
  89. }
  90. const args = [];
  91. {
  92. let curArg = arguments[0];
  93. if (curArg !== undefined) {
  94. curArg = conversions["long"](curArg, {
  95. context: "Failed to execute 'insertCell' on 'HTMLTableRowElement': parameter 1",
  96. globals: globalObject
  97. });
  98. } else {
  99. curArg = -1;
  100. }
  101. args.push(curArg);
  102. }
  103. return utils.tryWrapperForImpl(esValue[implSymbol].insertCell(...args));
  104. }
  105. deleteCell(index) {
  106. const esValue = this !== null && this !== undefined ? this : globalObject;
  107. if (!exports.is(esValue)) {
  108. throw new globalObject.TypeError(
  109. "'deleteCell' called on an object that is not a valid instance of HTMLTableRowElement."
  110. );
  111. }
  112. if (arguments.length < 1) {
  113. throw new globalObject.TypeError(
  114. `Failed to execute 'deleteCell' on 'HTMLTableRowElement': 1 argument required, but only ${arguments.length} present.`
  115. );
  116. }
  117. const args = [];
  118. {
  119. let curArg = arguments[0];
  120. curArg = conversions["long"](curArg, {
  121. context: "Failed to execute 'deleteCell' on 'HTMLTableRowElement': parameter 1",
  122. globals: globalObject
  123. });
  124. args.push(curArg);
  125. }
  126. ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
  127. try {
  128. return esValue[implSymbol].deleteCell(...args);
  129. } finally {
  130. ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
  131. }
  132. }
  133. get rowIndex() {
  134. const esValue = this !== null && this !== undefined ? this : globalObject;
  135. if (!exports.is(esValue)) {
  136. throw new globalObject.TypeError(
  137. "'get rowIndex' called on an object that is not a valid instance of HTMLTableRowElement."
  138. );
  139. }
  140. return esValue[implSymbol]["rowIndex"];
  141. }
  142. get sectionRowIndex() {
  143. const esValue = this !== null && this !== undefined ? this : globalObject;
  144. if (!exports.is(esValue)) {
  145. throw new globalObject.TypeError(
  146. "'get sectionRowIndex' called on an object that is not a valid instance of HTMLTableRowElement."
  147. );
  148. }
  149. return esValue[implSymbol]["sectionRowIndex"];
  150. }
  151. get cells() {
  152. const esValue = this !== null && this !== undefined ? this : globalObject;
  153. if (!exports.is(esValue)) {
  154. throw new globalObject.TypeError(
  155. "'get cells' called on an object that is not a valid instance of HTMLTableRowElement."
  156. );
  157. }
  158. return utils.getSameObject(this, "cells", () => {
  159. return utils.tryWrapperForImpl(esValue[implSymbol]["cells"]);
  160. });
  161. }
  162. get align() {
  163. const esValue = this !== null && this !== undefined ? this : globalObject;
  164. if (!exports.is(esValue)) {
  165. throw new globalObject.TypeError(
  166. "'get align' called on an object that is not a valid instance of HTMLTableRowElement."
  167. );
  168. }
  169. ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
  170. try {
  171. const value = esValue[implSymbol]._reflectGetTheContentAttribute("align");
  172. return value === null ? "" : value;
  173. } finally {
  174. ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
  175. }
  176. }
  177. set align(V) {
  178. const esValue = this !== null && this !== undefined ? this : globalObject;
  179. if (!exports.is(esValue)) {
  180. throw new globalObject.TypeError(
  181. "'set align' called on an object that is not a valid instance of HTMLTableRowElement."
  182. );
  183. }
  184. V = conversions["DOMString"](V, {
  185. context: "Failed to set the 'align' property on 'HTMLTableRowElement': The provided value",
  186. globals: globalObject
  187. });
  188. ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
  189. try {
  190. esValue[implSymbol]._reflectSetTheContentAttribute("align", V);
  191. } finally {
  192. ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
  193. }
  194. }
  195. get ch() {
  196. const esValue = this !== null && this !== undefined ? this : globalObject;
  197. if (!exports.is(esValue)) {
  198. throw new globalObject.TypeError(
  199. "'get ch' called on an object that is not a valid instance of HTMLTableRowElement."
  200. );
  201. }
  202. ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
  203. try {
  204. const value = esValue[implSymbol]._reflectGetTheContentAttribute("char");
  205. return value === null ? "" : value;
  206. } finally {
  207. ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
  208. }
  209. }
  210. set ch(V) {
  211. const esValue = this !== null && this !== undefined ? this : globalObject;
  212. if (!exports.is(esValue)) {
  213. throw new globalObject.TypeError(
  214. "'set ch' called on an object that is not a valid instance of HTMLTableRowElement."
  215. );
  216. }
  217. V = conversions["DOMString"](V, {
  218. context: "Failed to set the 'ch' property on 'HTMLTableRowElement': The provided value",
  219. globals: globalObject
  220. });
  221. ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
  222. try {
  223. esValue[implSymbol]._reflectSetTheContentAttribute("char", V);
  224. } finally {
  225. ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
  226. }
  227. }
  228. get chOff() {
  229. const esValue = this !== null && this !== undefined ? this : globalObject;
  230. if (!exports.is(esValue)) {
  231. throw new globalObject.TypeError(
  232. "'get chOff' called on an object that is not a valid instance of HTMLTableRowElement."
  233. );
  234. }
  235. ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
  236. try {
  237. const value = esValue[implSymbol]._reflectGetTheContentAttribute("charoff");
  238. return value === null ? "" : value;
  239. } finally {
  240. ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
  241. }
  242. }
  243. set chOff(V) {
  244. const esValue = this !== null && this !== undefined ? this : globalObject;
  245. if (!exports.is(esValue)) {
  246. throw new globalObject.TypeError(
  247. "'set chOff' called on an object that is not a valid instance of HTMLTableRowElement."
  248. );
  249. }
  250. V = conversions["DOMString"](V, {
  251. context: "Failed to set the 'chOff' property on 'HTMLTableRowElement': The provided value",
  252. globals: globalObject
  253. });
  254. ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
  255. try {
  256. esValue[implSymbol]._reflectSetTheContentAttribute("charoff", V);
  257. } finally {
  258. ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
  259. }
  260. }
  261. get vAlign() {
  262. const esValue = this !== null && this !== undefined ? this : globalObject;
  263. if (!exports.is(esValue)) {
  264. throw new globalObject.TypeError(
  265. "'get vAlign' called on an object that is not a valid instance of HTMLTableRowElement."
  266. );
  267. }
  268. ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
  269. try {
  270. const value = esValue[implSymbol]._reflectGetTheContentAttribute("valign");
  271. return value === null ? "" : value;
  272. } finally {
  273. ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
  274. }
  275. }
  276. set vAlign(V) {
  277. const esValue = this !== null && this !== undefined ? this : globalObject;
  278. if (!exports.is(esValue)) {
  279. throw new globalObject.TypeError(
  280. "'set vAlign' called on an object that is not a valid instance of HTMLTableRowElement."
  281. );
  282. }
  283. V = conversions["DOMString"](V, {
  284. context: "Failed to set the 'vAlign' property on 'HTMLTableRowElement': The provided value",
  285. globals: globalObject
  286. });
  287. ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
  288. try {
  289. esValue[implSymbol]._reflectSetTheContentAttribute("valign", V);
  290. } finally {
  291. ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
  292. }
  293. }
  294. get bgColor() {
  295. const esValue = this !== null && this !== undefined ? this : globalObject;
  296. if (!exports.is(esValue)) {
  297. throw new globalObject.TypeError(
  298. "'get bgColor' called on an object that is not a valid instance of HTMLTableRowElement."
  299. );
  300. }
  301. ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
  302. try {
  303. const value = esValue[implSymbol]._reflectGetTheContentAttribute("bgcolor");
  304. return value === null ? "" : value;
  305. } finally {
  306. ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
  307. }
  308. }
  309. set bgColor(V) {
  310. const esValue = this !== null && this !== undefined ? this : globalObject;
  311. if (!exports.is(esValue)) {
  312. throw new globalObject.TypeError(
  313. "'set bgColor' called on an object that is not a valid instance of HTMLTableRowElement."
  314. );
  315. }
  316. V = conversions["DOMString"](V, {
  317. context: "Failed to set the 'bgColor' property on 'HTMLTableRowElement': The provided value",
  318. globals: globalObject,
  319. treatNullAsEmptyString: true
  320. });
  321. ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
  322. try {
  323. esValue[implSymbol]._reflectSetTheContentAttribute("bgcolor", V);
  324. } finally {
  325. ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
  326. }
  327. }
  328. }
  329. Object.defineProperties(HTMLTableRowElement.prototype, {
  330. insertCell: { enumerable: true },
  331. deleteCell: { enumerable: true },
  332. rowIndex: { enumerable: true },
  333. sectionRowIndex: { enumerable: true },
  334. cells: { enumerable: true },
  335. align: { enumerable: true },
  336. ch: { enumerable: true },
  337. chOff: { enumerable: true },
  338. vAlign: { enumerable: true },
  339. bgColor: { enumerable: true },
  340. [Symbol.toStringTag]: { value: "HTMLTableRowElement", configurable: true }
  341. });
  342. ctorRegistry[interfaceName] = HTMLTableRowElement;
  343. Object.defineProperty(globalObject, interfaceName, {
  344. configurable: true,
  345. writable: true,
  346. value: HTMLTableRowElement
  347. });
  348. };
  349. const Impl = require("../../jsdom/living/nodes/HTMLTableRowElement-impl.js");