HTMLMeterElement.js 12 KB

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