CSSCounterStyleRule.js 13 KB

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