question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Non-breaking space acts different than other characters - outputs " " in template when passed via props

See original GitHub issue

Version

2.5.17

Reproduction link

https://codepen.io/avertes/pen/LYYpNRe https://jsfiddle.net/50wL7mdz/756973/

Steps to reproduce

  1. Create a new component that accepts a string prop.
  2. Display the prop within the component’s template.
  3. 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 with document.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:open
  • Created 5 years ago
  • Reactions:1
  • Comments:12 (2 by maintainers)

github_iconTop GitHub Comments

12reactions
grreeenncommented, Oct 21, 2019

as a workaround, try to put the JS escape code for   - \xa0

found here, worked for me in nonbreakinspacification function

    public static noBreakingSpaces(str: string): string {
        return str.replace(' ', '\xa0');
    }

strings returned by this function are being rendered with &nbsps instead of spaces.

3reactions
Eibxcommented, Nov 23, 2018

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/

Read more comments on GitHub >

github_iconTop 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 >
&nbsp 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found