You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The swapComponent/swapStyle/swapTemplate APIs do not work correctly in the following scenario (using swapStyle to illustrate):
/* initial state */// works - A is renderedswapStyle(a,b)// works - B is renderedswapStyle(b,a)// works - A is renderedswapStyle(a,b)// does not work! A is still rendered
There is a visited set to avoid infinite loops. However, if we have entries for both A -> B and B -> A, then calling this function with A will always return A. This is why the third swapStyle above doesn't work.
The text was updated successfully, but these errors were encountered:
nolanlawson
changed the title
[HMR] swapStyle() API does not work when swapping back and forth multiple times
[HMR] swapStyle() API does not work when swapping back and forth
Apr 16, 2024
nolanlawson
changed the title
[HMR] swapStyle() API does not work when swapping back and forth
[HMR] swap* APIs do not work when swapping content back and forth
Apr 16, 2024
nolanlawson
changed the title
[HMR] swap* APIs do not work when swapping content back and forth
[HMR] swap* APIs do not work when swapping back and forth multiple times
Apr 16, 2024
nolanlawson
changed the title
[HMR] swap* APIs do not work when swapping back and forth multiple times
[HMR] swap* APIs show stale content when swapping back and forth multiple times
Apr 16, 2024
This might not actually be an issue in practice, since our HMR implementation should re-evaluate the stylesheet function every time, not based on its string content. TBD.
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: