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

i18n component parses line break as a VNode #210

Closed
myst729 opened this issue Aug 20, 2017 · 0 comments · Fixed by #211
Closed

i18n component parses line break as a VNode #210

myst729 opened this issue Aug 20, 2017 · 0 comments · Fixed by #211

Comments

@myst729
Copy link
Contributor

myst729 commented Aug 20, 2017

vue & vue-i18n version

vue: 2.4.2
vue-i18n: 7.1.1

Reproduction Link

https://jsbin.com/hohalimepo/edit?html,js,output

What is Expected?

Both should render correct sentence.

What is actually happening?

The first one parses line break as a VNode

<i18n path="msg" tag="div">
  <strong>bold</strong>
  <em>italic</em>
</i18n>

image

So that the second slot in i18n string was replaced with the TextNode, which was the line break between two child elements.

image

I have to now write it like this.

<i18n path="msg" tag="div">
  <strong>bold</strong><em>italic</em>
</i18n>

image

I'm not sure whether this should be dealt with by vdom or by i18n lib, I prefer the latter. Nonetheless, for this particular functional component, I think only element nodes (nodeType === 1) should be considered. Since plain text can be easily moved to i18n message object.

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

Successfully merging a pull request may close this issue.

1 participant