Skip to content

Commit

Permalink
feat: Added support for document.images (#219)
Browse files Browse the repository at this point in the history
Co-authored-by: Cameron Wheeler <cwheeler@yelp.com>
  • Loading branch information
cwheel and Cameron Wheeler committed Jul 23, 2022
1 parent d648520 commit 10ba9db
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/lib/web-worker/worker-document.ts
Expand Up @@ -169,6 +169,12 @@ export const patchDocument = (
},
},

images: {
get() {
return getter(this, ['images']);
},
},

implementation: {
get() {
return {
Expand Down
4 changes: 4 additions & 0 deletions tests/platform/document/document.spec.ts
Expand Up @@ -96,4 +96,8 @@ test('document', async ({ page }) => {

const testVisibilityState = page.locator('#testVisibilityState');
await expect(testVisibilityState).toHaveText('visible');

const testImages = page.locator('#testDocumentImages');
const pageUrl = new URL(page.url());
await expect(testImages).toHaveText(`${pageUrl.origin}/fake.jpg`);
});
12 changes: 12 additions & 0 deletions tests/platform/document/index.html
Expand Up @@ -452,6 +452,18 @@ <h1 class="title">Document</h1>
</script>
</li>

<li>
<strong>document.images</strong>
<code id="testDocumentImages"></code>
<img src="/fake.jpg" />
<script type="text/partytown">
(function () {
const elm = document.getElementById('testDocumentImages');
elm.textContent = document.images[0].src;
})();
</script>
</li>

<script type="text/partytown">
(function () {
document.body.classList.add('completed');
Expand Down

1 comment on commit 10ba9db

@vercel
Copy link

@vercel vercel bot commented on 10ba9db Jul 23, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.