vuejs / repl

Vue SFC REPL as a Vue 3 component
https://repl-vuejs.vercel.app
MIT License
908 stars 163 forks source link

fix css attribute HMR failure #88

Closed Alfred-Skyblue closed 1 year ago

Alfred-Skyblue commented 1 year ago

After adding CSS properties to it, I noticed that they didn't take effect. While modifying the codeToEval, I tried using Promise.resolve().then and setTimeout(()=>{},0) to execute it, but it still didn't work. However, when I adjusted the timeout to 1ms, it started working. Did it internally use setTimeout? Interestingly, I observed that other synchronous operations were working fine. This situation has left me confused. Nevertheless, the current changes I made are effective.

demo

Reproducible steps:

  1. Open the demo.
  2. Delete the style tag.
  3. Restore the style tag.

https://github.com/vuejs/repl/assets/55641773/2ca91553-474a-4929-85c0-c7ea8e4897c8