HTMLTableSectionElement.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349
  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 = "HTMLTableSectionElement";
  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 'HTMLTableSectionElement'.`);
  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]["HTMLTableSectionElement"].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 HTMLTableSectionElement extends globalObject.HTMLElement {
  80. constructor() {
  81. return HTMLConstructor_jsdom_living_helpers_html_constructor(globalObject, interfaceName, new.target);
  82. }
  83. insertRow() {
  84. const esValue = this !== null && this !== undefined ? this : globalObject;
  85. if (!exports.is(esValue)) {
  86. throw new globalObject.TypeError(
  87. "'insertRow' called on an object that is not a valid instance of HTMLTableSectionElement."
  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 'insertRow' on 'HTMLTableSectionElement': parameter 1",
  96. globals: globalObject
  97. });
  98. } else {
  99. curArg = -1;
  100. }
  101. args.push(curArg);
  102. }
  103. return utils.tryWrapperForImpl(esValue[implSymbol].insertRow(...args));
  104. }
  105. deleteRow(index) {
  106. const esValue = this !== null && this !== undefined ? this : globalObject;
  107. if (!exports.is(esValue)) {
  108. throw new globalObject.TypeError(
  109. "'deleteRow' called on an object that is not a valid instance of HTMLTableSectionElement."
  110. );
  111. }
  112. if (arguments.length < 1) {
  113. throw new globalObject.TypeError(
  114. `Failed to execute 'deleteRow' on 'HTMLTableSectionElement': 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 'deleteRow' on 'HTMLTableSectionElement': 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].deleteRow(...args);
  129. } finally {
  130. ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
  131. }
  132. }
  133. get rows() {
  134. const esValue = this !== null && this !== undefined ? this : globalObject;
  135. if (!exports.is(esValue)) {
  136. throw new globalObject.TypeError(
  137. "'get rows' called on an object that is not a valid instance of HTMLTableSectionElement."
  138. );
  139. }
  140. return utils.getSameObject(this, "rows", () => {
  141. return utils.tryWrapperForImpl(esValue[implSymbol]["rows"]);
  142. });
  143. }
  144. get align() {
  145. const esValue = this !== null && this !== undefined ? this : globalObject;
  146. if (!exports.is(esValue)) {
  147. throw new globalObject.TypeError(
  148. "'get align' called on an object that is not a valid instance of HTMLTableSectionElement."
  149. );
  150. }
  151. ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
  152. try {
  153. const value = esValue[implSymbol]._reflectGetTheContentAttribute("align");
  154. return value === null ? "" : value;
  155. } finally {
  156. ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
  157. }
  158. }
  159. set align(V) {
  160. const esValue = this !== null && this !== undefined ? this : globalObject;
  161. if (!exports.is(esValue)) {
  162. throw new globalObject.TypeError(
  163. "'set align' called on an object that is not a valid instance of HTMLTableSectionElement."
  164. );
  165. }
  166. V = conversions["DOMString"](V, {
  167. context: "Failed to set the 'align' property on 'HTMLTableSectionElement': The provided value",
  168. globals: globalObject
  169. });
  170. ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
  171. try {
  172. esValue[implSymbol]._reflectSetTheContentAttribute("align", V);
  173. } finally {
  174. ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
  175. }
  176. }
  177. get ch() {
  178. const esValue = this !== null && this !== undefined ? this : globalObject;
  179. if (!exports.is(esValue)) {
  180. throw new globalObject.TypeError(
  181. "'get ch' called on an object that is not a valid instance of HTMLTableSectionElement."
  182. );
  183. }
  184. ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
  185. try {
  186. const value = esValue[implSymbol]._reflectGetTheContentAttribute("char");
  187. return value === null ? "" : value;
  188. } finally {
  189. ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
  190. }
  191. }
  192. set ch(V) {
  193. const esValue = this !== null && this !== undefined ? this : globalObject;
  194. if (!exports.is(esValue)) {
  195. throw new globalObject.TypeError(
  196. "'set ch' called on an object that is not a valid instance of HTMLTableSectionElement."
  197. );
  198. }
  199. V = conversions["DOMString"](V, {
  200. context: "Failed to set the 'ch' property on 'HTMLTableSectionElement': The provided value",
  201. globals: globalObject
  202. });
  203. ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
  204. try {
  205. esValue[implSymbol]._reflectSetTheContentAttribute("char", V);
  206. } finally {
  207. ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
  208. }
  209. }
  210. get chOff() {
  211. const esValue = this !== null && this !== undefined ? this : globalObject;
  212. if (!exports.is(esValue)) {
  213. throw new globalObject.TypeError(
  214. "'get chOff' called on an object that is not a valid instance of HTMLTableSectionElement."
  215. );
  216. }
  217. ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
  218. try {
  219. const value = esValue[implSymbol]._reflectGetTheContentAttribute("charoff");
  220. return value === null ? "" : value;
  221. } finally {
  222. ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
  223. }
  224. }
  225. set chOff(V) {
  226. const esValue = this !== null && this !== undefined ? this : globalObject;
  227. if (!exports.is(esValue)) {
  228. throw new globalObject.TypeError(
  229. "'set chOff' called on an object that is not a valid instance of HTMLTableSectionElement."
  230. );
  231. }
  232. V = conversions["DOMString"](V, {
  233. context: "Failed to set the 'chOff' property on 'HTMLTableSectionElement': The provided value",
  234. globals: globalObject
  235. });
  236. ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
  237. try {
  238. esValue[implSymbol]._reflectSetTheContentAttribute("charoff", V);
  239. } finally {
  240. ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
  241. }
  242. }
  243. get vAlign() {
  244. const esValue = this !== null && this !== undefined ? this : globalObject;
  245. if (!exports.is(esValue)) {
  246. throw new globalObject.TypeError(
  247. "'get vAlign' called on an object that is not a valid instance of HTMLTableSectionElement."
  248. );
  249. }
  250. ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
  251. try {
  252. const value = esValue[implSymbol]._reflectGetTheContentAttribute("valign");
  253. return value === null ? "" : value;
  254. } finally {
  255. ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
  256. }
  257. }
  258. set vAlign(V) {
  259. const esValue = this !== null && this !== undefined ? this : globalObject;
  260. if (!exports.is(esValue)) {
  261. throw new globalObject.TypeError(
  262. "'set vAlign' called on an object that is not a valid instance of HTMLTableSectionElement."
  263. );
  264. }
  265. V = conversions["DOMString"](V, {
  266. context: "Failed to set the 'vAlign' property on 'HTMLTableSectionElement': The provided value",
  267. globals: globalObject
  268. });
  269. ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
  270. try {
  271. esValue[implSymbol]._reflectSetTheContentAttribute("valign", V);
  272. } finally {
  273. ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
  274. }
  275. }
  276. }
  277. Object.defineProperties(HTMLTableSectionElement.prototype, {
  278. insertRow: { enumerable: true },
  279. deleteRow: { enumerable: true },
  280. rows: { enumerable: true },
  281. align: { enumerable: true },
  282. ch: { enumerable: true },
  283. chOff: { enumerable: true },
  284. vAlign: { enumerable: true },
  285. [Symbol.toStringTag]: { value: "HTMLTableSectionElement", configurable: true }
  286. });
  287. ctorRegistry[interfaceName] = HTMLTableSectionElement;
  288. Object.defineProperty(globalObject, interfaceName, {
  289. configurable: true,
  290. writable: true,
  291. value: HTMLTableSectionElement
  292. });
  293. };
  294. const Impl = require("../../jsdom/living/nodes/HTMLTableSectionElement-impl.js");