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

Binding a CSS variable in a component that uses a Ref on a loop of a custom component breaks Hot Module Reload #9617

Closed
noahgregory-basis opened this issue Nov 16, 2023 · 2 comments
Labels
duplicate This issue or pull request already exists

Comments

@noahgregory-basis
Copy link

noahgregory-basis commented Nov 16, 2023

Vue version

3.3.8

Link to minimal reproduction

https://github.com/noahgregory-basis/nuxt-test

Steps to reproduce

  1. Run npm run dev to start the dev server.
  2. Open browser to dev server and open the developer console.
  3. Comment out the console.log line in Bar.vue and save to trigger hot module reload.
  4. Observe the error:
    Uncaught (in promise) TypeError: Failed to execute 'observe' on 'MutationObserver': parameter 1 is not of type 'Node'.

This appears to happen in the useCssVars helper function. Specifically inside the onMounted callback, at the line (as seen below in the bundle):

    ob.observe(instance.subTree.el.parentNode, { childList: true });

What is expected?

No error occurs when hot-reloading.

What is actually happening?

Error occurs when hot-reloading.

System Info

No response

Any additional comments?

I have found that two circumstances need to exist for this error to appear:

  1. For some custom component:
    a. The component is given a v-for prop to render it multiple times,
    b. The component is given a ref prop to put the array of components in, and
    c. The name passed into ref is defined as a ref in <script setup> block; and
  2. A variable is defined in the <script setup> block and is used in v-bind in the <style> block.

Given where the error occurs, it seems item 2 is more of a culprit than item 1. However, item 1 still needs to exist, so it must be at least somewhat at fault. How, though, I have no idea.

@Disservin
Copy link
Contributor

Probably a duplicate of #9264

@Formulaaa
Copy link

I hava the same problem.The parentNode is "null" causes this problem. But when I use MutationObserver to monitor the parentNode, I find it has never been modified.

@github-actions github-actions bot locked and limited conversation to collaborators Jun 24, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

4 participants