From 1514420ad426ddf0b71c2bfb791c0837a78f3d35 Mon Sep 17 00:00:00 2001 From: ens13533 Date: Wed, 3 Jul 2024 10:33:59 +0300 Subject: [PATCH 1/2] added title attribute to img --- coral-component-card/src/scripts/Card.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/coral-component-card/src/scripts/Card.js b/coral-component-card/src/scripts/Card.js index eeb138ef5b..605b982e2a 100644 --- a/coral-component-card/src/scripts/Card.js +++ b/coral-component-card/src/scripts/Card.js @@ -94,6 +94,11 @@ const Card = Decorator(class extends BaseComponent(HTMLElement) { handle: 'asset', tagName: 'coral-card-asset', insert: function (asset) { + const coralTitle = this.querySelector('coral-card-title').textContent; + const imgElement = asset.querySelector('img'); + if (imgElement && coralTitle) { + asset.querySelector('img').setAttribute('title', coralTitle); + } this.insertBefore(asset, this.info || this._elements.wrapper || null); } }); From 6903136b8085c8d8b9439c700c9a2a000761693f Mon Sep 17 00:00:00 2001 From: ens13533 Date: Wed, 3 Jul 2024 10:51:31 +0300 Subject: [PATCH 2/2] added title attribute to img --- coral-component-card/src/scripts/Card.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/coral-component-card/src/scripts/Card.js b/coral-component-card/src/scripts/Card.js index 605b982e2a..52b3a0a1aa 100644 --- a/coral-component-card/src/scripts/Card.js +++ b/coral-component-card/src/scripts/Card.js @@ -94,10 +94,13 @@ const Card = Decorator(class extends BaseComponent(HTMLElement) { handle: 'asset', tagName: 'coral-card-asset', insert: function (asset) { - const coralTitle = this.querySelector('coral-card-title').textContent; + const coralTitle = this.querySelector('coral-card-title'); const imgElement = asset.querySelector('img'); if (imgElement && coralTitle) { - asset.querySelector('img').setAttribute('title', coralTitle); + const coralTitleTextContent = coralTitle.textContent; + if (coralTitleTextContent) { + imgElement.setAttribute('title', coralTitleTextContent); + } } this.insertBefore(asset, this.info || this._elements.wrapper || null); }