Non-breaking space acts different than other characters - outputs " " in template when passed via props
See original GitHub issueVersion
2.5.17
Reproduction link
https://codepen.io/avertes/pen/LYYpNRe https://jsfiddle.net/50wL7mdz/756973/
Steps to reproduce
- Create a new component that accepts a string prop.
- Display the prop within the component’s template.
- Use the component in a Vue application and pass a string containing a non-breaking space character for the prop.
What is expected?
The output should contain a non breaking space
What is actually happening?
The output shows
In the example provided I’ve made 3 cases
- First case is that
 
get turned into
- Second case is that in a long list of UTF-8 characters only
NON-BREAKING SPACE
is escaped. - And third when getting the same list of characters, but retrieving it from a regular
HTMLElement
withdocument.querySelector('#test').title
the character aren’t escape.
Note: When copying the non-breaking space character it might turn into a regular space in the clipboard. Therefor use https://en.wikipedia.org/wiki/Non-breaking_space#Keyboard_entry_methods to make sure how to insert the character.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:12 (2 by maintainers)
Top Results From Across the Web
ReactJS render string with non-breaking spaces
I have some props that has a string that could contain characters such as &. It also contains spaces. I want to replace...
Read more >359303 - Non-breaking spaces (nbsp) not copied as such
Its purpose is to prevent a line break between words or other runs of non-whitespace characters. Here are a few examples where non-breaking...
Read more >  and HTML Space Challenges and Tricks | Mailtrap Blog
Nbsp stands for non-breaking space, meaning that strings separated with this entity will not be separated and put into separate lines. But ...
Read more >ETSET Typeset an Electronic Text - Fourmilab
Quote matching is performed only when generating an output format which ... No white space characters other than blanks and line separators are...
Read more >Changelog for pandoc-1.12.0.1 | Hackage
Filters are always passed the name of the output format, so their behavior ... + Pandoc will now act as if link references...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
as a workaround, try to put the JS escape code for
-\xa0
found here, worked for me in nonbreakinspacification function
strings returned by this function are being rendered with
 
s instead of spaces.Yeah - it does seem to be related the way Vue parses html attributes in general.
I’ve made a similar example based of @approached example https://jsfiddle.net/onbzk0m6/3/