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

toArray adds a stray character element to array tail #52

Open
copperseed opened this issue Apr 16, 2020 · 6 comments
Open

toArray adds a stray character element to array tail #52

copperseed opened this issue Apr 16, 2020 · 6 comments
Labels

Comments

@copperseed
Copy link

Thanks for a great package - works well!

One issue I've found is that the toArray method adds a stray array element at the end with what appears to be an empty string but is actually some type of hidden character. I've tried to log it with various methods but gotten nothing. It causes some issues in IE specifically trying to render the string. This I find only happens for certain emojis such as ✌️ and ✍️ . There are others as well.

@enzoferey
Copy link
Collaborator

Hi @copperseed, thanks for reporting. It looks like there indeed an issue about it.

I wonder what effect does it have on the render, could you send some screenshots ?

As a quick fix for you, you can filter out these pseudo empty string by console logging current output, copying the symbol and then write something like toArray(text).filter(item => item !== "️").

I don't have in mind anymore what this character is used for so hard to tell if we could be removing it ourselves or not. I will let you know over here 👍

@copperseed
Copy link
Author

copperseed commented Apr 20, 2020

Hey @enzoferey, it's not actually an empty string - there's an artefact in there. IE 11 logs it simply as a square (unknown character). Using the unidecode package (https://www.npmjs.com/package/unidecode) it returns as [?] so my workaround was to do

        if (typeof current === "string") {
            if (unidecode(current) === '[?]') return previous;
            return previous + current;
        }

@enzoferey
Copy link
Collaborator

Hey @copperseed, I know it's not an actually empty string, that's why I wrote above "pseudo empty string". You don't need to add another dependency, if you console log this special character and copy paste it into your code as I wrote above you can filter it out 👍

@copperseed
Copy link
Author

Hey @copperseed, I know it's not an actually empty string, that's why I wrote above "pseudo empty string". You don't need to add another dependency, if you console log this special character and copy paste it into your code as I wrote above you can filter it out 👍

I have tried console log for this and it logs an empty string. No idea how to view this character otherwise 🤣

@enzoferey
Copy link
Collaborator

enzoferey commented Apr 20, 2020

It logs an empty string but it's not. If you copy paste it into your code and you filter that "empty" string as in my previous comment you will see it removes the item from the array.

@copperseed
Copy link
Author

It logs an empty string but it's not. If you copy paste it into your code and you filter that "empty" string as in my previous comment you will see it removes the item from the array.

This fails in IE 11 as it still logs it's missing character block so using unidecode solves that. This is only a real issue in IE - even though the bug is there in other browsers, I haven't had problems with other browsers.

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