Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/silly-taxis-dance.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@lynx-js/web-elements": patch
---

Remove the default lazy-loading attribute from x-image elements.
1 change: 1 addition & 0 deletions .github/lynx-stack.instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ applyTo: "packages/web-platform/web-elements/**/*"
---

When updating web element APIs, add targeted Playwright tests in packages/web-platform/web-elements/tests/web-elements.spec.ts and keep changes minimal.
Ensure Playwright browsers are installed (pnpm exec playwright install --with-deps <browser>) before running web-elements tests.
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,7 @@ export const templateXImage = (attributes: { src?: string }) => {
'detected <script, this is a potential XSS attack, please check your src',
);
}
return `<img part="img" alt="" loading="lazy" id="img" ${
src ? `src="${src}"` : ''
}/> `;
return `<img part="img" alt="" id="img" ${src ? `src="${src}"` : ''}/> `;
};

export const templateFilterImage = templateXImage;
Expand Down
12 changes: 12 additions & 0 deletions packages/web-platform/web-elements/tests/web-elements.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1711,6 +1711,18 @@ test.describe('web-elements test suite', () => {
// Verify that the referrerpolicy attribute is set to 'no-referrer' on the internal img element
expect(referrerpolicyValue).toBe('no-referrer');
});
test('should not have loading attribute by default', async ({ page }) => {
const title = 'x-image/basic';
await gotoWebComponentPage(page, title);

const loadingValue = await page.evaluate(() => {
const xImage = document.querySelector('x-image');
const img = xImage?.shadowRoot?.querySelector('#img');
return img?.getAttribute('loading');
});

expect(loadingValue).toBeNull();
});
});

test.describe('x-list', () => {
Expand Down
Loading