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

Null values for v-text directive not handled in SSR #6572

Closed
pi0 opened this issue Sep 11, 2017 · 0 comments
Closed

Null values for v-text directive not handled in SSR #6572

pi0 opened this issue Sep 11, 2017 · 0 comments
Labels

Comments

@pi0
Copy link
Contributor

pi0 commented Sep 11, 2017

Version

2.4.2

Reproduction link

https://glitch.com/edit/#!/v-text

https://v-text.glitch.me/html
https://v-text.glitch.me/text

Steps to reproduce

Try to render <span v-text="x"></span> where x is is null or undefined

What is expected?

It may be gracefully handled just like v-html directive (see notes below) or client side version of v-text.

What is actually happening?

Throwing an internal TypeError:

Cannot read property 'replace' of undefined
function escape (s) {
  return s.replace(/[<>"&]/g, escapeChar)
}

Seems the simple fix would be defining a default value for s parameter in util.js (or better do a string type check on value)

Related to nuxt/nuxt#1638

Some Notes

v-html behaviour also differs in SSR and client. SSR renders v-html: <span>null</span> while it changes into <span></span> on client side. Seems <span v-html="foo"> is being optimized into '<span>' + (_vm.foo). So we can change it into (_vm.foo|| '') to handle this inconsistency during SSR render.

@yyx990803 yyx990803 added the bug label Sep 13, 2017
ztlevi pushed a commit to ztlevi/vue that referenced this issue Feb 14, 2018
f2009 pushed a commit to f2009/vue that referenced this issue Jan 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants