HTMLImageElement.js 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906
  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 serializeURLwhatwg_url = require("whatwg-url").serializeURL;
  11. const parseNonNegativeInteger_jsdom_living_helpers_strings =
  12. require("../../jsdom/living/helpers/strings.js").parseNonNegativeInteger;
  13. const implSymbol = utils.implSymbol;
  14. const ctorRegistrySymbol = utils.ctorRegistrySymbol;
  15. const HTMLElement = require("./HTMLElement.js");
  16. const interfaceName = "HTMLImageElement";
  17. exports.is = value => {
  18. return utils.isObject(value) && Object.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation;
  19. };
  20. exports.isImpl = value => {
  21. return utils.isObject(value) && value instanceof Impl.implementation;
  22. };
  23. exports.convert = (globalObject, value, { context = "The provided value" } = {}) => {
  24. if (exports.is(value)) {
  25. return utils.implForWrapper(value);
  26. }
  27. throw new globalObject.TypeError(`${context} is not of type 'HTMLImageElement'.`);
  28. };
  29. function makeWrapper(globalObject, newTarget) {
  30. let proto;
  31. if (newTarget !== undefined) {
  32. proto = newTarget.prototype;
  33. }
  34. if (!utils.isObject(proto)) {
  35. proto = globalObject[ctorRegistrySymbol]["HTMLImageElement"].prototype;
  36. }
  37. return Object.create(proto);
  38. }
  39. exports.create = (globalObject, constructorArgs, privateData) => {
  40. const wrapper = makeWrapper(globalObject);
  41. return exports.setup(wrapper, globalObject, constructorArgs, privateData);
  42. };
  43. exports.createImpl = (globalObject, constructorArgs, privateData) => {
  44. const wrapper = exports.create(globalObject, constructorArgs, privateData);
  45. return utils.implForWrapper(wrapper);
  46. };
  47. exports._internalSetup = (wrapper, globalObject) => {
  48. HTMLElement._internalSetup(wrapper, globalObject);
  49. };
  50. exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => {
  51. privateData.wrapper = wrapper;
  52. exports._internalSetup(wrapper, globalObject);
  53. Object.defineProperty(wrapper, implSymbol, {
  54. value: new Impl.implementation(globalObject, constructorArgs, privateData),
  55. configurable: true
  56. });
  57. wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
  58. if (Impl.init) {
  59. Impl.init(wrapper[implSymbol]);
  60. }
  61. return wrapper;
  62. };
  63. exports.new = (globalObject, newTarget) => {
  64. const wrapper = makeWrapper(globalObject, newTarget);
  65. exports._internalSetup(wrapper, globalObject);
  66. Object.defineProperty(wrapper, implSymbol, {
  67. value: Object.create(Impl.implementation.prototype),
  68. configurable: true
  69. });
  70. wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
  71. if (Impl.init) {
  72. Impl.init(wrapper[implSymbol]);
  73. }
  74. return wrapper[implSymbol];
  75. };
  76. const exposed = new Set(["Window"]);
  77. exports.install = (globalObject, globalNames) => {
  78. if (!globalNames.some(globalName => exposed.has(globalName))) {
  79. return;
  80. }
  81. const ctorRegistry = utils.initCtorRegistry(globalObject);
  82. class HTMLImageElement extends globalObject.HTMLElement {
  83. constructor() {
  84. return HTMLConstructor_jsdom_living_helpers_html_constructor(globalObject, interfaceName, new.target);
  85. }
  86. get alt() {
  87. const esValue = this !== null && this !== undefined ? this : globalObject;
  88. if (!exports.is(esValue)) {
  89. throw new globalObject.TypeError(
  90. "'get alt' called on an object that is not a valid instance of HTMLImageElement."
  91. );
  92. }
  93. ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
  94. try {
  95. const value = esValue[implSymbol]._reflectGetTheContentAttribute("alt");
  96. return value === null ? "" : value;
  97. } finally {
  98. ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
  99. }
  100. }
  101. set alt(V) {
  102. const esValue = this !== null && this !== undefined ? this : globalObject;
  103. if (!exports.is(esValue)) {
  104. throw new globalObject.TypeError(
  105. "'set alt' called on an object that is not a valid instance of HTMLImageElement."
  106. );
  107. }
  108. V = conversions["DOMString"](V, {
  109. context: "Failed to set the 'alt' property on 'HTMLImageElement': The provided value",
  110. globals: globalObject
  111. });
  112. ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
  113. try {
  114. esValue[implSymbol]._reflectSetTheContentAttribute("alt", V);
  115. } finally {
  116. ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
  117. }
  118. }
  119. get src() {
  120. const esValue = this !== null && this !== undefined ? this : globalObject;
  121. if (!exports.is(esValue)) {
  122. throw new globalObject.TypeError(
  123. "'get src' called on an object that is not a valid instance of HTMLImageElement."
  124. );
  125. }
  126. ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
  127. try {
  128. const impl = esValue[implSymbol];
  129. const value = impl._reflectGetTheContentAttribute("src");
  130. if (value === null) {
  131. return "";
  132. }
  133. const document = impl._ownerDocument;
  134. if (this._srcURLCacheKey === value && this._baseURLCache === document._baseURLCache) {
  135. return this._srcURLCache;
  136. }
  137. this._srcURLCacheKey = value;
  138. this._baseURLCache = document._baseURLCache;
  139. const urlRecord = document.encodingParseAURL(value);
  140. if (urlRecord !== null) {
  141. this._srcURLCache = serializeURLwhatwg_url(urlRecord);
  142. return this._srcURLCache;
  143. }
  144. this._srcURLCache = conversions.USVString(value);
  145. return this._srcURLCache;
  146. } finally {
  147. ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
  148. }
  149. }
  150. set src(V) {
  151. const esValue = this !== null && this !== undefined ? this : globalObject;
  152. if (!exports.is(esValue)) {
  153. throw new globalObject.TypeError(
  154. "'set src' called on an object that is not a valid instance of HTMLImageElement."
  155. );
  156. }
  157. V = conversions["USVString"](V, {
  158. context: "Failed to set the 'src' property on 'HTMLImageElement': The provided value",
  159. globals: globalObject
  160. });
  161. ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
  162. try {
  163. esValue[implSymbol]._reflectSetTheContentAttribute("src", V);
  164. } finally {
  165. ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
  166. }
  167. }
  168. get srcset() {
  169. const esValue = this !== null && this !== undefined ? this : globalObject;
  170. if (!exports.is(esValue)) {
  171. throw new globalObject.TypeError(
  172. "'get srcset' called on an object that is not a valid instance of HTMLImageElement."
  173. );
  174. }
  175. ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
  176. try {
  177. const value = esValue[implSymbol]._reflectGetTheContentAttribute("srcset");
  178. return value === null ? "" : conversions.USVString(value);
  179. } finally {
  180. ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
  181. }
  182. }
  183. set srcset(V) {
  184. const esValue = this !== null && this !== undefined ? this : globalObject;
  185. if (!exports.is(esValue)) {
  186. throw new globalObject.TypeError(
  187. "'set srcset' called on an object that is not a valid instance of HTMLImageElement."
  188. );
  189. }
  190. V = conversions["USVString"](V, {
  191. context: "Failed to set the 'srcset' property on 'HTMLImageElement': The provided value",
  192. globals: globalObject
  193. });
  194. ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
  195. try {
  196. esValue[implSymbol]._reflectSetTheContentAttribute("srcset", V);
  197. } finally {
  198. ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
  199. }
  200. }
  201. get sizes() {
  202. const esValue = this !== null && this !== undefined ? this : globalObject;
  203. if (!exports.is(esValue)) {
  204. throw new globalObject.TypeError(
  205. "'get sizes' called on an object that is not a valid instance of HTMLImageElement."
  206. );
  207. }
  208. ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
  209. try {
  210. const value = esValue[implSymbol]._reflectGetTheContentAttribute("sizes");
  211. return value === null ? "" : value;
  212. } finally {
  213. ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
  214. }
  215. }
  216. set sizes(V) {
  217. const esValue = this !== null && this !== undefined ? this : globalObject;
  218. if (!exports.is(esValue)) {
  219. throw new globalObject.TypeError(
  220. "'set sizes' called on an object that is not a valid instance of HTMLImageElement."
  221. );
  222. }
  223. V = conversions["DOMString"](V, {
  224. context: "Failed to set the 'sizes' property on 'HTMLImageElement': The provided value",
  225. globals: globalObject
  226. });
  227. ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
  228. try {
  229. esValue[implSymbol]._reflectSetTheContentAttribute("sizes", V);
  230. } finally {
  231. ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
  232. }
  233. }
  234. get crossOrigin() {
  235. const esValue = this !== null && this !== undefined ? this : globalObject;
  236. if (!exports.is(esValue)) {
  237. throw new globalObject.TypeError(
  238. "'get crossOrigin' called on an object that is not a valid instance of HTMLImageElement."
  239. );
  240. }
  241. ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
  242. try {
  243. return esValue[implSymbol]._reflectGetTheContentAttribute("crossorigin");
  244. } finally {
  245. ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
  246. }
  247. }
  248. set crossOrigin(V) {
  249. const esValue = this !== null && this !== undefined ? this : globalObject;
  250. if (!exports.is(esValue)) {
  251. throw new globalObject.TypeError(
  252. "'set crossOrigin' called on an object that is not a valid instance of HTMLImageElement."
  253. );
  254. }
  255. if (V === null || V === undefined) {
  256. V = null;
  257. } else {
  258. V = conversions["DOMString"](V, {
  259. context: "Failed to set the 'crossOrigin' property on 'HTMLImageElement': The provided value",
  260. globals: globalObject
  261. });
  262. }
  263. ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
  264. try {
  265. if (V === null) {
  266. esValue[implSymbol]._reflectDeleteTheContentAttribute("crossorigin");
  267. } else {
  268. esValue[implSymbol]._reflectSetTheContentAttribute("crossorigin", V);
  269. }
  270. } finally {
  271. ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
  272. }
  273. }
  274. get useMap() {
  275. const esValue = this !== null && this !== undefined ? this : globalObject;
  276. if (!exports.is(esValue)) {
  277. throw new globalObject.TypeError(
  278. "'get useMap' called on an object that is not a valid instance of HTMLImageElement."
  279. );
  280. }
  281. ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
  282. try {
  283. const value = esValue[implSymbol]._reflectGetTheContentAttribute("usemap");
  284. return value === null ? "" : value;
  285. } finally {
  286. ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
  287. }
  288. }
  289. set useMap(V) {
  290. const esValue = this !== null && this !== undefined ? this : globalObject;
  291. if (!exports.is(esValue)) {
  292. throw new globalObject.TypeError(
  293. "'set useMap' called on an object that is not a valid instance of HTMLImageElement."
  294. );
  295. }
  296. V = conversions["DOMString"](V, {
  297. context: "Failed to set the 'useMap' property on 'HTMLImageElement': The provided value",
  298. globals: globalObject
  299. });
  300. ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
  301. try {
  302. esValue[implSymbol]._reflectSetTheContentAttribute("usemap", V);
  303. } finally {
  304. ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
  305. }
  306. }
  307. get isMap() {
  308. const esValue = this !== null && this !== undefined ? this : globalObject;
  309. if (!exports.is(esValue)) {
  310. throw new globalObject.TypeError(
  311. "'get isMap' called on an object that is not a valid instance of HTMLImageElement."
  312. );
  313. }
  314. ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
  315. try {
  316. return esValue[implSymbol]._reflectGetTheContentAttribute("ismap") !== null;
  317. } finally {
  318. ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
  319. }
  320. }
  321. set isMap(V) {
  322. const esValue = this !== null && this !== undefined ? this : globalObject;
  323. if (!exports.is(esValue)) {
  324. throw new globalObject.TypeError(
  325. "'set isMap' called on an object that is not a valid instance of HTMLImageElement."
  326. );
  327. }
  328. V = conversions["boolean"](V, {
  329. context: "Failed to set the 'isMap' property on 'HTMLImageElement': The provided value",
  330. globals: globalObject
  331. });
  332. ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
  333. try {
  334. if (V) {
  335. esValue[implSymbol]._reflectSetTheContentAttribute("ismap", "");
  336. } else {
  337. esValue[implSymbol]._reflectDeleteTheContentAttribute("ismap");
  338. }
  339. } finally {
  340. ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
  341. }
  342. }
  343. get width() {
  344. const esValue = this !== null && this !== undefined ? this : globalObject;
  345. if (!exports.is(esValue)) {
  346. throw new globalObject.TypeError(
  347. "'get width' called on an object that is not a valid instance of HTMLImageElement."
  348. );
  349. }
  350. ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
  351. try {
  352. return esValue[implSymbol]["width"];
  353. } finally {
  354. ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
  355. }
  356. }
  357. set width(V) {
  358. const esValue = this !== null && this !== undefined ? this : globalObject;
  359. if (!exports.is(esValue)) {
  360. throw new globalObject.TypeError(
  361. "'set width' called on an object that is not a valid instance of HTMLImageElement."
  362. );
  363. }
  364. V = conversions["unsigned long"](V, {
  365. context: "Failed to set the 'width' property on 'HTMLImageElement': The provided value",
  366. globals: globalObject
  367. });
  368. ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
  369. try {
  370. esValue[implSymbol]["width"] = V;
  371. } finally {
  372. ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
  373. }
  374. }
  375. get height() {
  376. const esValue = this !== null && this !== undefined ? this : globalObject;
  377. if (!exports.is(esValue)) {
  378. throw new globalObject.TypeError(
  379. "'get height' called on an object that is not a valid instance of HTMLImageElement."
  380. );
  381. }
  382. ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
  383. try {
  384. return esValue[implSymbol]["height"];
  385. } finally {
  386. ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
  387. }
  388. }
  389. set height(V) {
  390. const esValue = this !== null && this !== undefined ? this : globalObject;
  391. if (!exports.is(esValue)) {
  392. throw new globalObject.TypeError(
  393. "'set height' called on an object that is not a valid instance of HTMLImageElement."
  394. );
  395. }
  396. V = conversions["unsigned long"](V, {
  397. context: "Failed to set the 'height' property on 'HTMLImageElement': The provided value",
  398. globals: globalObject
  399. });
  400. ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
  401. try {
  402. esValue[implSymbol]["height"] = V;
  403. } finally {
  404. ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
  405. }
  406. }
  407. get naturalWidth() {
  408. const esValue = this !== null && this !== undefined ? this : globalObject;
  409. if (!exports.is(esValue)) {
  410. throw new globalObject.TypeError(
  411. "'get naturalWidth' called on an object that is not a valid instance of HTMLImageElement."
  412. );
  413. }
  414. return esValue[implSymbol]["naturalWidth"];
  415. }
  416. get naturalHeight() {
  417. const esValue = this !== null && this !== undefined ? this : globalObject;
  418. if (!exports.is(esValue)) {
  419. throw new globalObject.TypeError(
  420. "'get naturalHeight' called on an object that is not a valid instance of HTMLImageElement."
  421. );
  422. }
  423. return esValue[implSymbol]["naturalHeight"];
  424. }
  425. get complete() {
  426. const esValue = this !== null && this !== undefined ? this : globalObject;
  427. if (!exports.is(esValue)) {
  428. throw new globalObject.TypeError(
  429. "'get complete' called on an object that is not a valid instance of HTMLImageElement."
  430. );
  431. }
  432. return esValue[implSymbol]["complete"];
  433. }
  434. get currentSrc() {
  435. const esValue = this !== null && this !== undefined ? this : globalObject;
  436. if (!exports.is(esValue)) {
  437. throw new globalObject.TypeError(
  438. "'get currentSrc' called on an object that is not a valid instance of HTMLImageElement."
  439. );
  440. }
  441. return esValue[implSymbol]["currentSrc"];
  442. }
  443. get name() {
  444. const esValue = this !== null && this !== undefined ? this : globalObject;
  445. if (!exports.is(esValue)) {
  446. throw new globalObject.TypeError(
  447. "'get name' called on an object that is not a valid instance of HTMLImageElement."
  448. );
  449. }
  450. ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
  451. try {
  452. const value = esValue[implSymbol]._reflectGetTheContentAttribute("name");
  453. return value === null ? "" : value;
  454. } finally {
  455. ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
  456. }
  457. }
  458. set name(V) {
  459. const esValue = this !== null && this !== undefined ? this : globalObject;
  460. if (!exports.is(esValue)) {
  461. throw new globalObject.TypeError(
  462. "'set name' called on an object that is not a valid instance of HTMLImageElement."
  463. );
  464. }
  465. V = conversions["DOMString"](V, {
  466. context: "Failed to set the 'name' property on 'HTMLImageElement': The provided value",
  467. globals: globalObject
  468. });
  469. ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
  470. try {
  471. esValue[implSymbol]._reflectSetTheContentAttribute("name", V);
  472. } finally {
  473. ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
  474. }
  475. }
  476. get lowsrc() {
  477. const esValue = this !== null && this !== undefined ? this : globalObject;
  478. if (!exports.is(esValue)) {
  479. throw new globalObject.TypeError(
  480. "'get lowsrc' called on an object that is not a valid instance of HTMLImageElement."
  481. );
  482. }
  483. ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
  484. try {
  485. const impl = esValue[implSymbol];
  486. const value = impl._reflectGetTheContentAttribute("lowsrc");
  487. if (value === null) {
  488. return "";
  489. }
  490. const document = impl._ownerDocument;
  491. if (this._lowsrcURLCacheKey === value && this._baseURLCache === document._baseURLCache) {
  492. return this._lowsrcURLCache;
  493. }
  494. this._lowsrcURLCacheKey = value;
  495. this._baseURLCache = document._baseURLCache;
  496. const urlRecord = document.encodingParseAURL(value);
  497. if (urlRecord !== null) {
  498. this._lowsrcURLCache = serializeURLwhatwg_url(urlRecord);
  499. return this._lowsrcURLCache;
  500. }
  501. this._lowsrcURLCache = conversions.USVString(value);
  502. return this._lowsrcURLCache;
  503. } finally {
  504. ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
  505. }
  506. }
  507. set lowsrc(V) {
  508. const esValue = this !== null && this !== undefined ? this : globalObject;
  509. if (!exports.is(esValue)) {
  510. throw new globalObject.TypeError(
  511. "'set lowsrc' called on an object that is not a valid instance of HTMLImageElement."
  512. );
  513. }
  514. V = conversions["USVString"](V, {
  515. context: "Failed to set the 'lowsrc' property on 'HTMLImageElement': The provided value",
  516. globals: globalObject
  517. });
  518. ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
  519. try {
  520. esValue[implSymbol]._reflectSetTheContentAttribute("lowsrc", V);
  521. } finally {
  522. ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
  523. }
  524. }
  525. get align() {
  526. const esValue = this !== null && this !== undefined ? this : globalObject;
  527. if (!exports.is(esValue)) {
  528. throw new globalObject.TypeError(
  529. "'get align' called on an object that is not a valid instance of HTMLImageElement."
  530. );
  531. }
  532. ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
  533. try {
  534. const value = esValue[implSymbol]._reflectGetTheContentAttribute("align");
  535. return value === null ? "" : value;
  536. } finally {
  537. ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
  538. }
  539. }
  540. set align(V) {
  541. const esValue = this !== null && this !== undefined ? this : globalObject;
  542. if (!exports.is(esValue)) {
  543. throw new globalObject.TypeError(
  544. "'set align' called on an object that is not a valid instance of HTMLImageElement."
  545. );
  546. }
  547. V = conversions["DOMString"](V, {
  548. context: "Failed to set the 'align' property on 'HTMLImageElement': The provided value",
  549. globals: globalObject
  550. });
  551. ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
  552. try {
  553. esValue[implSymbol]._reflectSetTheContentAttribute("align", V);
  554. } finally {
  555. ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
  556. }
  557. }
  558. get hspace() {
  559. const esValue = this !== null && this !== undefined ? this : globalObject;
  560. if (!exports.is(esValue)) {
  561. throw new globalObject.TypeError(
  562. "'get hspace' called on an object that is not a valid instance of HTMLImageElement."
  563. );
  564. }
  565. ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
  566. try {
  567. let value = esValue[implSymbol]._reflectGetTheContentAttribute("hspace");
  568. if (value !== null) {
  569. value = parseNonNegativeInteger_jsdom_living_helpers_strings(value);
  570. if (value !== null && value >= 0 && value <= 2147483647) {
  571. return value;
  572. }
  573. }
  574. return 0;
  575. } finally {
  576. ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
  577. }
  578. }
  579. set hspace(V) {
  580. const esValue = this !== null && this !== undefined ? this : globalObject;
  581. if (!exports.is(esValue)) {
  582. throw new globalObject.TypeError(
  583. "'set hspace' called on an object that is not a valid instance of HTMLImageElement."
  584. );
  585. }
  586. V = conversions["unsigned long"](V, {
  587. context: "Failed to set the 'hspace' property on 'HTMLImageElement': The provided value",
  588. globals: globalObject
  589. });
  590. ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
  591. try {
  592. const newValue = V <= 2147483647 && V >= 0 ? V : 0;
  593. esValue[implSymbol]._reflectSetTheContentAttribute("hspace", String(newValue));
  594. } finally {
  595. ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
  596. }
  597. }
  598. get vspace() {
  599. const esValue = this !== null && this !== undefined ? this : globalObject;
  600. if (!exports.is(esValue)) {
  601. throw new globalObject.TypeError(
  602. "'get vspace' called on an object that is not a valid instance of HTMLImageElement."
  603. );
  604. }
  605. ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
  606. try {
  607. let value = esValue[implSymbol]._reflectGetTheContentAttribute("vspace");
  608. if (value !== null) {
  609. value = parseNonNegativeInteger_jsdom_living_helpers_strings(value);
  610. if (value !== null && value >= 0 && value <= 2147483647) {
  611. return value;
  612. }
  613. }
  614. return 0;
  615. } finally {
  616. ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
  617. }
  618. }
  619. set vspace(V) {
  620. const esValue = this !== null && this !== undefined ? this : globalObject;
  621. if (!exports.is(esValue)) {
  622. throw new globalObject.TypeError(
  623. "'set vspace' called on an object that is not a valid instance of HTMLImageElement."
  624. );
  625. }
  626. V = conversions["unsigned long"](V, {
  627. context: "Failed to set the 'vspace' property on 'HTMLImageElement': The provided value",
  628. globals: globalObject
  629. });
  630. ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
  631. try {
  632. const newValue = V <= 2147483647 && V >= 0 ? V : 0;
  633. esValue[implSymbol]._reflectSetTheContentAttribute("vspace", String(newValue));
  634. } finally {
  635. ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
  636. }
  637. }
  638. get longDesc() {
  639. const esValue = this !== null && this !== undefined ? this : globalObject;
  640. if (!exports.is(esValue)) {
  641. throw new globalObject.TypeError(
  642. "'get longDesc' called on an object that is not a valid instance of HTMLImageElement."
  643. );
  644. }
  645. ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
  646. try {
  647. const impl = esValue[implSymbol];
  648. const value = impl._reflectGetTheContentAttribute("longdesc");
  649. if (value === null) {
  650. return "";
  651. }
  652. const document = impl._ownerDocument;
  653. if (this._longdescURLCacheKey === value && this._baseURLCache === document._baseURLCache) {
  654. return this._longdescURLCache;
  655. }
  656. this._longdescURLCacheKey = value;
  657. this._baseURLCache = document._baseURLCache;
  658. const urlRecord = document.encodingParseAURL(value);
  659. if (urlRecord !== null) {
  660. this._longdescURLCache = serializeURLwhatwg_url(urlRecord);
  661. return this._longdescURLCache;
  662. }
  663. this._longdescURLCache = conversions.USVString(value);
  664. return this._longdescURLCache;
  665. } finally {
  666. ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
  667. }
  668. }
  669. set longDesc(V) {
  670. const esValue = this !== null && this !== undefined ? this : globalObject;
  671. if (!exports.is(esValue)) {
  672. throw new globalObject.TypeError(
  673. "'set longDesc' called on an object that is not a valid instance of HTMLImageElement."
  674. );
  675. }
  676. V = conversions["USVString"](V, {
  677. context: "Failed to set the 'longDesc' property on 'HTMLImageElement': The provided value",
  678. globals: globalObject
  679. });
  680. ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
  681. try {
  682. esValue[implSymbol]._reflectSetTheContentAttribute("longdesc", V);
  683. } finally {
  684. ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
  685. }
  686. }
  687. get border() {
  688. const esValue = this !== null && this !== undefined ? this : globalObject;
  689. if (!exports.is(esValue)) {
  690. throw new globalObject.TypeError(
  691. "'get border' called on an object that is not a valid instance of HTMLImageElement."
  692. );
  693. }
  694. ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
  695. try {
  696. const value = esValue[implSymbol]._reflectGetTheContentAttribute("border");
  697. return value === null ? "" : value;
  698. } finally {
  699. ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
  700. }
  701. }
  702. set border(V) {
  703. const esValue = this !== null && this !== undefined ? this : globalObject;
  704. if (!exports.is(esValue)) {
  705. throw new globalObject.TypeError(
  706. "'set border' called on an object that is not a valid instance of HTMLImageElement."
  707. );
  708. }
  709. V = conversions["DOMString"](V, {
  710. context: "Failed to set the 'border' property on 'HTMLImageElement': The provided value",
  711. globals: globalObject,
  712. treatNullAsEmptyString: true
  713. });
  714. ceReactionsPreSteps_jsdom_living_helpers_custom_elements(globalObject);
  715. try {
  716. esValue[implSymbol]._reflectSetTheContentAttribute("border", V);
  717. } finally {
  718. ceReactionsPostSteps_jsdom_living_helpers_custom_elements(globalObject);
  719. }
  720. }
  721. }
  722. Object.defineProperties(HTMLImageElement.prototype, {
  723. alt: { enumerable: true },
  724. src: { enumerable: true },
  725. srcset: { enumerable: true },
  726. sizes: { enumerable: true },
  727. crossOrigin: { enumerable: true },
  728. useMap: { enumerable: true },
  729. isMap: { enumerable: true },
  730. width: { enumerable: true },
  731. height: { enumerable: true },
  732. naturalWidth: { enumerable: true },
  733. naturalHeight: { enumerable: true },
  734. complete: { enumerable: true },
  735. currentSrc: { enumerable: true },
  736. name: { enumerable: true },
  737. lowsrc: { enumerable: true },
  738. align: { enumerable: true },
  739. hspace: { enumerable: true },
  740. vspace: { enumerable: true },
  741. longDesc: { enumerable: true },
  742. border: { enumerable: true },
  743. [Symbol.toStringTag]: { value: "HTMLImageElement", configurable: true }
  744. });
  745. ctorRegistry[interfaceName] = HTMLImageElement;
  746. Object.defineProperty(globalObject, interfaceName, {
  747. configurable: true,
  748. writable: true,
  749. value: HTMLImageElement
  750. });
  751. };
  752. const Impl = require("../../jsdom/living/nodes/HTMLImageElement-impl.js");