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

fix: DomParser usage in SSR #1180

Merged
merged 2 commits into from
Feb 9, 2023
Merged

fix: DomParser usage in SSR #1180

merged 2 commits into from
Feb 9, 2023

Conversation

sean-perkins
Copy link
Contributor

@sean-perkins sean-perkins commented Feb 8, 2023

The DomParser class is not available in a server context (only available in the browser). The previous changes were causing issues in SSR when trying to load an icon.

This PR removes the implementation of instantiating the DomParser, regardless of the environment.

Resolves: #1179

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
Copy link
Contributor

@liamdebeasi liamdebeasi left a comment

Choose a reason for hiding this comment

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

Tested with dev build 6.1.3-dev.11675958242.15132c48 on the repo provided in #1179, and this fix seems to work.

I don't know if we need the Build.isBrowser flag here and in the Icon component:

if (Build.isBrowser && this.isVisible) {

getSvgContent is only called if Build.isBrowser is true in loadIcon, so adding the Build check in getSvgContent seems redundant.

The original problem was that we were running new DOMParser() regardless of environment.

@sean-perkins sean-perkins marked this pull request as ready for review February 9, 2023 16:38
@sean-perkins sean-perkins merged commit 8c412f6 into main Feb 9, 2023
@sean-perkins sean-perkins deleted the fix/ionicons-ssr branch February 9, 2023 17:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bug: DOMParser is not defined
2 participants