Skip to content

Commit e30bca8

Browse files
committed
fix(web): emit onImagePress when src is empty
1 parent 63e9ad8 commit e30bca8

2 files changed

Lines changed: 7 additions & 7 deletions

File tree

.playwright/tests/enrichedTextPress.spec.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ test.describe('EnrichedText image press', () => {
225225
await expect(imagePress(page)).toHaveText('null');
226226
});
227227

228-
test('pressing an empty-src placeholder does not emit onImagePress', async ({
228+
test('pressing an empty-src placeholder does emit onImagePress', async ({
229229
page,
230230
}) => {
231231
await gotoTestEnrichedText(page);
@@ -240,7 +240,11 @@ test.describe('EnrichedText image press', () => {
240240

241241
await page.locator(`${sel.displayInner} img`).click();
242242

243-
await expect(imagePress(page)).toHaveText('null');
243+
await expect
244+
.poll(async () =>
245+
JSON.parse((await imagePress(page).textContent()) || 'null')
246+
)
247+
.toEqual({ image: { uri: '', width: 40, height: 40 } });
244248
});
245249

246250
test('pressing a broken-URL placeholder does emit onImagePress', async ({

src/web/htmlExtensions/usePressInteractions.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,7 @@ export function usePressInteractions(
9090
function getImageAttributes(
9191
image: HTMLImageElement
9292
): ImageAttributes | undefined {
93-
const uri = image.getAttribute('src');
94-
95-
if (!uri) {
96-
return undefined;
97-
}
93+
const uri = image.getAttribute('src') ?? '';
9894

9995
const { width, height } = getImageDimensions(image);
10096

0 commit comments

Comments
 (0)