I have a relatively large AngularJS component called Extend Text. This past weekend I was working on adding parsing functionality so you could use it for something like a query builder but I started to run into a really strange problem I had not come across before.
The issue I ran into was that when retrieving the value from the textarea element, if the textarea ended with a space, it was not your standard space, it was a unicode non-breaking space (
\u00a0). When I did a
console.log() on the value, it looked like a space however when doing a comparison to
The textarea had the
white-space property set to
nowrap. Now I can't remember why I did that, I sure I had a good reason as that time, but it was not needed. After reading the MDN documentation on the
white-space property, it did make since what was happen. With setting the
white-space property to
nowrap, it was causing the ending space of the textarea to be saved as a unicode non-breaking space
\u00a0. Luckily, I did not need the property so I was able to fix the issue just by removing it.