Uncaught TypeError: n.setAttribute is not a function when ssr client-side hydration
See original GitHub issueVersion
2.6.10
Reproduction link
https://github.com/yinxin630/vue-issue-example
Steps to reproduce
- clone and npm i
- run
npm run build
andnpm run build:ssr
- run
node src/ssr.js
- render app.js with ssr get result
<div id="app" data-server-rendered="true"><!----><h2>2222222222</h2></div>
- open in browser. client-side hydration will throw error
Uncaught TypeError: n.setAttribute is not a function
What is expected?
client-side hydration success
What is actually happening?
throw error Uncaught TypeError: n.setAttribute is not a function
I found this when debug. vue call n.setAttribute('class', 'm-image-padding')
but n is a comment node.
In app.js
I use v-if
. It will be true when ssr but be false when csr.
I don’t know if there is something wrong with my usage or the logic of vue client-side hydration.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:6
- Comments:13 (2 by maintainers)
Top Results From Across the Web
TypeError: setAttribute is not a function in JavaScript
To solve the "setAttribute is not a function" error, make sure to only call the setAttribute method on valid DOM elements and place...
Read more >VueJS2 - SSR - Select element - setAttribute is not a function
n.setAttribute is not a function But everything appears to be standard vue code when it comes to my component code above using the...
Read more >Starsgeometry[0].Setattribute Is Not A Function - ADocLib
Uncaught TypeError : Cannot read property 'setAttribute' of null. By: LazarusRisingin that case the element doesn't exist yet in the. We can use...
Read more >error - typeerror: render is not a function contextapi - You.com
Faced TypeError: render is not a function when using Context API ... open in browser. client-side hydration will throw error Uncaught TypeError: n....
Read more >javascript - this.setAttribute is not a function - Stack Overflow
To fix the context issue you can replace Update checkForMatch() with checkForMatch.bind(this)(); but you also seem to have another issue in ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Yes i have same issue any suggestion
I have the exact same problem, a value is false on ssr, true on csr, I have a v-if to display or not a NuxtLink. Upon hydration, console displays
TypeError: el.setAttribute is not a function
.Note :
yarn dev
v-show
instead ofv-if
v-if
has a correspondingv-else