SSR problem with empty text node in render function
Vue version
3.2.45
Link to minimal reproduction
Steps to reproduce
Click the button in the Playground example above. Note the console error. The UI also does not update to show the new text.
What is expected?
No error.
What is actually happening?
Uncaught (in promise) TypeError: Cannot set properties of null (setting 'nodeValue')
at setText (runtime-dom.esm-browser.js:9332:24)
at processText (runtime-dom.esm-browser.js:6536:17)
at patch (runtime-dom.esm-browser.js:6491:17)
at patchKeyedChildren (runtime-dom.esm-browser.js:7274:17)
at patchChildren (runtime-dom.esm-browser.js:7217:21)
at patchElement (runtime-dom.esm-browser.js:6731:13)
at processElement (runtime-dom.esm-browser.js:6592:13)
at patch (runtime-dom.esm-browser.js:6509:21)
at patchKeyedChildren (runtime-dom.esm-browser.js:7274:17)
at patchChildren (runtime-dom.esm-browser.js:7217:21)
Any additional comments?
If you turn off SSR mode in the Playground then everything works fine.
The text node must be empty initially to hit the problem. Any other content seems to be enough to make it work.
I'd imagine there's a problem with the hydration process and the text node not being created for the empty string. However, there isn't a hydration warning, it only fails when trying to change the text.
I wasn't able to reproduce the problem using a template. Both {{ text }}
and v-text="text"
seemed to work fine.
While h('p', [text.value])
fails, similar attempts such as h('p', text.value)
and h('p', [text.value, h('span')])
work fine.
Are there any plans on fixing this?
This is still happening on 3.4.10 and is heavily affecting when using vuetify components.
Related vuetify issue
Solved!
replace this:
h('p', [ text.value ])
with this:
h('p',text.value)
just remove the square bracket