feat: handle select tags

This commit is contained in:
amhsirak
2024-12-20 13:55:48 +05:30
parent e823e7bb4f
commit 60b901a1a0

View File

@@ -53,7 +53,14 @@ export const getElementInformation = async (
info.url = (element as HTMLAnchorElement).href;
info.innerText = element.innerText ?? '';
} else if (element?.tagName === 'IMG') {
info.imageUrl = (element as HTMLImageElement).src;
info.imageUrl = (element as HTMLImageElement).src;
} else if (element?.tagName === 'SELECT') {
const selectElement = element as HTMLSelectElement;
info.innerText = selectElement.options[selectElement.selectedIndex]?.text ?? '';
info.attributes = {
...info.attributes,
selectedValue: selectElement.value,
};
} else {
info.hasOnlyText = element?.children?.length === 0 &&
element?.innerText?.length > 0;