feat: check if alt text present in img tag

This commit is contained in:
karishmas6
2024-08-21 23:11:51 +05:30
parent 7338dcce0e
commit 489096095f

View File

@@ -30,10 +30,14 @@ const getAttributeOptions = (tagName: string, elementInfo: ElementInfo | null):
{ label: `URL: ${elementInfo.url}`, value: 'href' } { label: `URL: ${elementInfo.url}`, value: 'href' }
]; ];
case 'img': case 'img':
return [ const options: AttributeOption[] = [];
{ label: `Alt Text: ${elementInfo.innerText}`, value: 'alt' }, if (elementInfo.innerText) {
{ label: `Source URL: ${elementInfo.imageUrl}`, value: 'src' } options.push({ label: `Alt Text: ${elementInfo.innerText}`, value: 'alt' });
]; }
if (elementInfo.imageUrl) {
options.push({ label: `Source URL: ${elementInfo.imageUrl}`, value: 'src' });
}
return options;
default: default:
return [{ label: `Text: ${elementInfo.innerText}`, value: 'innerText' }]; return [{ label: `Text: ${elementInfo.innerText}`, value: 'innerText' }];
} }