Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: update extended client:visible to use an object instead of a string #9596

Merged
merged 6 commits into from
Jan 4, 2024

Conversation

Princesseuh
Copy link
Member

Changes

Revert #9363 and redo it using an object instead of a string, that way it can supports options we'll add in the future.

Testing

Tested manually, like the original PR.

Docs

Will update docs!

Copy link

changeset-bot bot commented Jan 3, 2024

🦋 Changeset detected

Latest commit: 8cbb65d

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions bot added pkg: astro Related to the core `astro` package (scope) pr: docs A PR that includes documentation for review labels Jan 3, 2024
Copy link
Contributor

github-actions bot commented Jan 3, 2024

⚖️ Bundle Size Check

Latest commit: 8cbb65d

File Old Size New Size Change
client:visible 271 B 301 B + 30 B

Copy link
Member

@natemoo-re natemoo-re left a comment

Choose a reason for hiding this comment

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

Looks good! Can we add a test that these arguments are properly encoded in the HTML?

.changeset/three-owls-drop.md Outdated Show resolved Hide resolved
.changeset/three-owls-drop.md Outdated Show resolved Hide resolved
packages/astro/src/runtime/client/visible.ts Show resolved Hide resolved
Copy link
Member

@natemoo-re natemoo-re left a comment

Choose a reason for hiding this comment

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

Nice test! Thank you!

const ioOptions = {
rootMargin: typeof options.value === 'string' ? options.value : undefined,
const rawOptions =
typeof options.value === 'object' ? (options.value as ClientVisibleOptions) : undefined;
Copy link
Member

Choose a reason for hiding this comment

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

Final nit: this technically adds support for all IntersectionObserverInit values, but our types are narrowed to only support Pick<IntersectionObserverInit, 'rootMargin'>. Is that desired?

Copy link
Member Author

Choose a reason for hiding this comment

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

It doesn't, see the code below

@Princesseuh Princesseuh merged commit fbc2697 into main Jan 4, 2024
15 checks passed
@Princesseuh Princesseuh deleted the update/client-visible-options branch January 4, 2024 00:44
@astrobot-houston astrobot-houston mentioned this pull request Jan 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg: astro Related to the core `astro` package (scope) pr: docs A PR that includes documentation for review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants