-
-
Notifications
You must be signed in to change notification settings - Fork 9k
Description
Vue version
3.5.13
Link to minimal reproduction
Steps to reproduce
- Open the provided reproduction link.
- Click the
Tab Aradio button. The span with the textin Awill be rendered due to thev-ifdirective. - Click the
Tab Bradio button. Thein Aspan will disappear, and the span with the textin Bwill be rendered instead. - Finally, click the
Tab Cradio button. At this point:- An error will appear in the console:
TypeError: null is not an object (evaluating 'e.parentNode'). - Although nothing should be rendered (as controlled by the
v-ifdirective), thein Bspan remains visible.
- An error will appear in the console:
What is expected?
As defined in the <template> block of the reproduction example, the v-if directive should ensure that the spans are rendered or not rendered according to the specified conditions.
What is actually happening?
It appears that when clicking Tab C, the previously existing span node is not properly removed, causing the error. The error seems to occur at the following location:
core/packages/runtime-dom/src/nodeOps.ts
Lines 49 to 54 in 6eb29d3
| remove: child => { | |
| const parent = child.parentNode | |
| if (parent) { | |
| parent.removeChild(child) | |
| } | |
| }, |
Interestingly, if the comment near the first v-if directive line in the example is removed, the error does not occur.
Additionally, this issue only happens in production mode and does not occur in dev mode.
System Info
No response
Any additional comments?
This issue also occurs on v3.4.24 the lowest available version in Vue SFC Playground.