Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

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

domPropsInnerHTML incorrect markup #90

Closed
alidcast opened this issue Jul 21, 2017 · 12 comments · Fixed by #92
Closed

domPropsInnerHTML incorrect markup #90

alidcast opened this issue Jul 21, 2017 · 12 comments · Fixed by #92
Labels

Comments

@alidcast
Copy link

alidcast commented Jul 21, 2017

I'm trying to render HTML using JSX.

For example:

  <div>
      <div domPropsInnerHTML={ this.body } />
 </div>

However I'm getting the following error:

The client-side rendered virtual DOM tree is not matching server-rendered content. This is likely caused by incorrect HTML markup, for example nesting block-level elements inside <p>, or missing <tbody>. Bailing hydration and performing full client-side render.

When I try the same exact HTML using the v-html directive in a vue template, the error disapears.

<div>
  <div v-html="body">
</div>

I would resort to using that, but I'm trying to use create a helper component for nuxtent that based on data renders a dynamic component or HTML at runtime, so that vue components could easily be used inside markdown.

@nickmessing
Copy link
Member

Hello @alidcastano, thank you for the report but it's not enough information, can you please provide a link to repository where this happens?

@alidcast
Copy link
Author

alidcast commented Jul 21, 2017

Here's the repo: https://github.com/nuxt-community/nuxtent.

You can see the error in action if you run the docs. Go to any documentation page and press refresh.

cd docs
npm install
npm run dev

And I provided a link to the exact place in the source code above.

Let me know if you need any other information!

@alidcast
Copy link
Author

alidcast commented Jul 24, 2017

@nickmessing Any update on this? Just trying to see how I should update the docs for Nuxtent... 😬

@nickmessing
Copy link
Member

@alidcastano, sorry, totally forgot about it, will take a look in the next hours.

@alidcast
Copy link
Author

Awesome, thanks!

@alidcast
Copy link
Author

alidcast commented Aug 2, 2017

@nickmessing Did you have a chance to look into it?

@nickmessing
Copy link
Member

@alidcastano, unfortunately no, had really busy time at work, but looks like I will have time today

@whtsky
Copy link
Contributor

whtsky commented Aug 15, 2017

Any updates on this?

@whtsky
Copy link
Contributor

whtsky commented Aug 15, 2017

Found that

h('pre', {
  domProps: {
    innerHTML: 'content',
  },
})

works and

h('pre', {
  domProps: {
    innerHTML: 'content',
  },
}, [])

doesn't.

@nickmessing
Copy link
Member

Oh, thank you for that finding, I didn't have time for this issue but since you tracked it down it can be easily fixed, thank you for the effort @whtsky.

@nickmessing
Copy link
Member

@alidcastano, are you sure v-html works?
I get that error on both:

<template>
  <div v-html="'<h1>Hey</h1>'">Hello</div>
</template>

and

<script>
export default {
  render () {
    return <div domPropsInnerHTML={`<h2>Hey</h2>`}>Hello</div>
  }
}
</script>

Looks like an SSR issue.

@nickmessing
Copy link
Member

Discussion continuer ad vuejs/vue#6519

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants