Skip to content

Uncaught TypeError: n.setAttribute is not a function when ssr client-side hydration #10937

@yinxin630

Description

@yinxin630

Version

2.6.10

Reproduction link

https://github.com/yinxin630/vue-issue-example

Steps to reproduce

  1. clone and npm i
  2. run npm run build and npm run build:ssr
  3. run node src/ssr.js
  4. render app.js with ssr get result
<div id="app" data-server-rendered="true"><!----><h2>2222222222</h2></div>
  1. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions