添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement . We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

https://github.com/nickmessing/vue-ssr-issue

Steps to reproduce

Use domPropsInnerHTML in JSX or v-html in Vue Template.

  • Clone the repo
  • npm install
  • npm run dev
  • Open http://localhost:3000 and http://localhost:3000/jsx
  • What is expected?

    No warning in console.

    What is actually happening?

    DOM Mismatching error.

    v-html works fine when there are no children, but fails if there are.

    One option is to completely ignore innerHTML and v-html in vue-ssr. Basically commenting this line solves the problem.

    Another option is evaluating innerHTML before comparing DOM snapshots so you get value from innerHTML on static SSR-rendered website without DOM Mismatch.

    Third option is ignoring children in createElment if there is innerHTML domProp. I think this one is the best.

    Still seeing an error if i replace the <h1>Hey</h1> in index.vue and <h2>Hey</h2> in jsx.vue with with &quot;<svg><path/></svg>

    server innerHTML:  &quot;<svg><path/></svg>
    client innerHTML:  "<svg><path></path></svg>
    

    EDIT: my mistake, it looks to only be an issue in jsx.vue. but i've also noticed &quot; breaks it too

    @yyx990803 I ran into a similar issue in a functional component using innerHTML to render the entity &times;.

    The &times; is the default value for a functional component prop (which can be changed to other HTML markup by the user)

    SSR renders the inner HTML as &times;, but the browser when using innerHTML converts some entities to actual UTF-8 characters (i.e. &times; is converted by the browser, via native innerHTML, to ×)

    Ultimately this causes rehydration to bail and re-render the component (and spew errors in dev mode)

    A few other HTML entities can also fail hydration when used in innerHTML: &hellip;, &raquo;, &laquo;, etc.

    Minimal markup to recreate SSR hydration bail issue:

    export default {
      functional: true,
      props: {
        icon: { type: String, default '&times;' }
      render(h, { props }) {
        return h('button', { domProps: { innerHTML: props.icon } });
    

    using a SFC template, (non functional component with v-html) the issue doesn't appear.

    I have an issue when working on transforming data that I receive from server. Let's say that server send data as string html content: <h1>Hi<h1> I want then to do some transformation in this element and add a data attribute like content: <h1 data-name="title">Hi with data attribue</h1> and render that in component with data attribute SSR .
    Any idea how can I achieve this?
    I appreciate any help!