Skip to content

Commit 9ea7ea4

Browse files
Use dataset properties for banner images
Replace setAttribute/getAttribute usage for per-image data attributes with element.dataset access in game_detail.js. Values are now written to bigImgsEl.dataset.imgSrc{n} / imgDesc{n} and read back via dataset, simplifying the code and aligning with standard DOM dataset usage.
1 parent 1922f17 commit 9ea7ea4

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

gh-pages-template/assets/js/game_detail.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ function setupGameBanner(data) {
1919
bigImgsEl.dataset.numImg = data.artworks.length;
2020
data.artworks.forEach((artwork, index) => {
2121
const imgNum = index + 1;
22-
bigImgsEl.setAttribute(`data-img-src-${imgNum}`, igdbImageUrl(artwork.url, "t_screenshot_huge_2x"));
22+
bigImgsEl.dataset[`imgSrc${imgNum}`] = igdbImageUrl(artwork.url, "t_screenshot_huge_2x");
2323
});
2424

2525
// Add big-img class and img-desc span to existing header
@@ -470,8 +470,8 @@ function initGameBanner() {
470470

471471
// Set initial image
472472
const getImgInfo = function(imgNum) {
473-
const src = bigImgsEl.getAttribute(`data-img-src-${imgNum}`);
474-
const desc = bigImgsEl.getAttribute(`data-img-desc-${imgNum}`);
473+
const src = bigImgsEl.dataset[`imgSrc${imgNum}`];
474+
const desc = bigImgsEl.dataset[`imgDesc${imgNum}`];
475475
return { src, desc };
476476
};
477477

0 commit comments

Comments
 (0)