HTMLTableColElement.js 12 KB

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