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

fix regex bug in IE where parseTypenames didn't always work properly #23

Closed
wants to merge 1 commit into from

Conversation

localpcguy
Copy link

Fixes #18 - updates the regex

the regex /^|\s+/ splits a string into it's individual characters. So something like "end".trim().split(/^|\s+/) in Internet Explorer 11 outputs [ "e", "n", "d" ]. In modern browsers, it outputs [ "end" ] as expected.

The regex /\s+/ works in both Internet Explorer 11 and modern browsers. Added a filter that maintains the behavior where it removes empty strings and keeps them from being processed through the map function.

@luastoned
Copy link

luastoned commented May 14, 2020

I thought I had the same issue, but in a plain IE11 tab this works just fine.
("start").split(/^|\s+/) -> ["start"]

Turns out redundant polyfills can break the split function in IE11.

@localpcguy check out zloirock/core-js#741 and zloirock/core-js#751

@Fil
Copy link
Member

Fil commented May 14, 2020

thank you!

@Fil Fil closed this May 14, 2020
@localpcguy
Copy link
Author

Thanks, I'll take a look and see if it's imported twice. The interesting this was that I was pretty sure when I was testing this I could reproduce in IE directly in the console. But it is possible that it was in a tab that had the polyfill loaded, hence messing with the results. I appreciate the information! 👍

adorableseulgi added a commit to adorableseulgi/d3 that referenced this pull request Jun 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Why is ^|\s+ used instead of just \s+ in .split()?
3 participants