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: check for server before creating treewalker from document #5681

Merged
merged 5 commits into from
Jul 16, 2024

Conversation

SaadBazaz
Copy link
Contributor

Hey,

I've been trying to get Material Components to work in NextJS SSG. All other components work fine except for Dialog, which throws the error document is not defined.

Upon inspection, the reason is because Dialog uses document.treeWalker upon initialization. I've added a check to initialize it as an empty object typecasted to TreeWalker, so that it works fine in SSG.

Tested, works ok. However, I'd love to know if there's a better way, instead of typecasting.

Copy link
Collaborator

@asyncLiz asyncLiz left a comment

Choose a reason for hiding this comment

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

Good catch! One small change request to have stricter types

dialog/internal/dialog.ts Outdated Show resolved Hide resolved
@asyncLiz asyncLiz self-requested a review July 15, 2024 23:15
Copy link
Collaborator

@asyncLiz asyncLiz left a comment

Choose a reason for hiding this comment

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

Thank you!

@asyncLiz asyncLiz self-assigned this Jul 15, 2024
@copybara-service copybara-service bot merged commit 2021596 into material-components:main Jul 16, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants