-
Notifications
You must be signed in to change notification settings - Fork 382
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
[HMR] swap*
APIs show stale content when swapping back and forth multiple times
#4154
Comments
nolanlawson
changed the title
[HMR]
[HMR] Apr 16, 2024
swapStyle()
API does not work when swapping back and forth multiple timesswapStyle()
API does not work when swapping back and forth
nolanlawson
changed the title
[HMR]
[HMR] Apr 16, 2024
swapStyle()
API does not work when swapping back and forthswap*
APIs do not work when swapping content back and forth
nolanlawson
changed the title
[HMR]
[HMR] Apr 16, 2024
swap*
APIs do not work when swapping content back and forthswap*
APIs do not work when swapping back and forth multiple times
nolanlawson
changed the title
[HMR]
[HMR] Apr 16, 2024
swap*
APIs do not work when swapping back and forth multiple timesswap*
APIs show stale content when swapping back and forth multiple times
nolanlawson
added a commit
to nolanlawson/lwc-1
that referenced
this issue
Apr 16, 2024
This might not actually be an issue in practice, since our HMR implementation should re-evaluate the |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The
swapComponent
/swapStyle
/swapTemplate
APIs do not work correctly in the following scenario (usingswapStyle
to illustrate):The reason for this is this line:
lwc/packages/@lwc/engine-core/src/framework/hot-swaps.ts
Line 187 in e7377d2
The
swappedStyleMap
only ever grows – it never shrinks. So after swapping A and B a few times, we end up with the mappings:Next, consider this code:
lwc/packages/@lwc/engine-core/src/framework/hot-swaps.ts
Lines 110 to 120 in e7377d2
There is a
visited
set to avoid infinite loops. However, if we have entries for bothA -> B
andB -> A
, then calling this function withA
will always returnA
. This is why the thirdswapStyle
above doesn't work.Related: #4115
Minimal repro: nolanlawson@3a135df
The text was updated successfully, but these errors were encountered: