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

test: ssr-vue example error when routerChanged #5677

Merged
merged 1 commit into from
Nov 15, 2021

Conversation

zhangyuang
Copy link
Contributor

@zhangyuang zhangyuang commented Nov 14, 2021

Description

In ssr-vue, when i click change router from Home to About and then change router from About to Home will be error caused by below code

// Home.vue
const url = import.meta.env.SSR
  ? import.meta.url
  : document.querySelector('.import-meta-url').textContent

When there code is evaluated, current page dom struct is the page of About.vue without <div class="import-meta-url"></div> node
image

image

Additional context


What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

Before submitting the PR, please make sure you do the following

  • Read the Contributing Guidelines.
  • Read the Pull Request Guidelines and follow the Commit Convention.
  • Check that there isn't already a PR that solves the problem the same way to avoid creating a duplicate.
  • Provide a description in this PR that addresses what the PR is solving, or reference the issue that it solves (e.g. fixes #123).
  • Ideally, include relevant tests that fail without this PR but pass with it.

@zhangyuang
Copy link
Contributor Author

zhangyuang commented Nov 14, 2021

Mention #5268, even if i reset to this commit, the behavior remain error
cc @patak-js @antfu

.github/workflows/ci.yml Outdated Show resolved Hide resolved
@zhangyuang
Copy link
Contributor Author

@patak-js has removed unused code

@patak-dev
Copy link
Member

Could you explain a bit more what this PR is doing? It looks like you extended the test case, and CI is passing with it, but I think I'm missing something about the fix you did here.

@zhangyuang
Copy link
Contributor Author

zhangyuang commented Nov 14, 2021

If you don't add these code in About.vue, in home page when you click router-link to go to about page which is normal but and then in about page when you click router-link to go back to home page will be error caused by below code

// Home.vue
const url = import.meta.env.SSR
  ? import.meta.url
  : document.querySelector('.import-meta-url').textContent

Because document.querySelector('.import-meta-url') is undefined

@Shinigami92 Shinigami92 added test p1-chore Doesn't change code behavior (priority) labels Nov 15, 2021
@patak-dev patak-dev changed the title fix(ssr): ssr-vue example error when routerChanged test: ssr-vue example error when routerChanged Nov 15, 2021
@patak-dev patak-dev merged commit 2dcb042 into vitejs:main Nov 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p1-chore Doesn't change code behavior (priority) test
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants