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

Vue renders unexpected "undefined" when v-if condition changes #4107

Closed
pvorb opened this issue Nov 4, 2016 · 2 comments
Closed

Vue renders unexpected "undefined" when v-if condition changes #4107

pvorb opened this issue Nov 4, 2016 · 2 comments
Labels

Comments

@pvorb
Copy link

pvorb commented Nov 4, 2016

Vue renders the text node "undefined" as the first child of an element that appears through a changed v-if condition (same applies for v-show) if it replaces an element that uses v-html.

Vue.js version

2.0.2, 2.0.3 (no other versions tested)

Reproduction Link

http://jsfiddle.net/5sH6A/860/

Steps to reproduce

In the JSFiddle, click the text "click me!" and you'll see the unexpected text "undefined" before <p>[deleted]</p>.

Using a template like this one:

<div>
  <div v-if="comment.status !== 'DELETED'" class="platon-text" v-html="comment.text" v-on:click="remove"></div>
  <div v-else class="platon-text"><p>[deleted]</p></div>
</div>

When comment.status changes from 'PUBLIC' to 'DELETED', instead of only showing the v-else part of the template, an unexpected undefined is rendered.

What is Expected?

The nodes from the template

<div class="platon-text"><p>[deleted]</p></div>

should be rendered.

What is actually happening?

The nodes equivalent to

<div v-else class="platon-text">undefined<p>[deleted]</p></div>

are rendered.

@pvorb pvorb changed the title Vue renders "undefined" when v-if condition changes Vue renders undexpected "undefined" when v-if condition changes Nov 4, 2016
@pvorb pvorb changed the title Vue renders undexpected "undefined" when v-if condition changes Vue renders unexpected "undefined" when v-if condition changes Nov 4, 2016
@pvorb
Copy link
Author

pvorb commented Nov 4, 2016

Using v-html on the first element seems to play an important role in this issue. It's sufficient to set v-html="''". Once you remove the directive though, everything is rendered just fine.

@defcc
Copy link
Member

defcc commented Nov 4, 2016

Seems to be a bug at first glance, thanks @pvorb for your reporting.

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