Core-js: IE11 + [email protected] String.prototype.split doesn't work with regexp

Created on 15 Jan 2020  Â·  16Comments  Â·  Source: zloirock/core-js

Screen Shot 2020-01-15 at 9 40 26 PM

repo to reproduce
https://github.com/kmsheng/core-js-bug

Note that core-js was imported twice,
one in src/js/index.js and the other one in assets/js/default.js

simlar issue
https://github.com/zloirock/core-js/issues/741

help wanted

Most helpful comment

I took a deeper dive into this issue. The problem is caused by this line. It turns out regexp.exec and regexpExec are different references when polyfill is loaded twice.

All 16 comments

i encountered the same bug, and can confirm that importing core-js into two js files is the root cause. importing it in only one file fixes the problem.

I'm also running into the same issue. My code path results in a second import which causes the bug to manifest.

In case this helps someone: https://github.com/github/fetch/issues/748
It would be great to identify which version of IE11 is/are affected, but it seems pretty recent to me, probably the last build.

Hi everyone. I am facing the same issue. It is still reproduced in IE11 with the latest version of core-js. However the scenario is pretty tricky to reproduce. So I created a minimal repo with needed steps. Hope it helps.

Hi, the issue is reproducible with other regexp too for example '/test/'.split(/\W/) is returning ["/", "t", "e", "s", "t", "/"] but should return ["", "test", ""].

Please show your npm list | grep core-js

@slowcheetah, will result of yarn list --pattern core-js work for you?

├─ [email protected]
└─ [email protected]

I took a deeper dive into this issue. The problem is caused by this line. It turns out regexp.exec and regexpExec are different references when polyfill is loaded twice.

Is there an older version of core-js that does not show this issue? It looks like there were changes related to adding more regexp.exec requires in 3.6.2
Would a downgrade to 3.6.1 work?

I downgraded to 3.5.0 yesterday and it works for me.

The bug was introduced by version 3.6.0 due to support of y flag. In version 3.5.0 exec was never patched in IE.

is reverting the sticky flag support considered?

@toxik Not yet. But I think about it, because I can’t make it work correctly and break nothing

@slowcheetah have you got any news regarding a revert/fix ? thanks

you can upgrade XRegExp to v4.4.0 instead – https://github.com/slevithan/xregexp/issues/300

same problem with 3.8.0.
I put a .replace() before call String.split() as a short term fix :
str.replace(someRegexp/g, ' \n').split('\n')

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ajbowler picture ajbowler  Â·  3Comments

yusidi picture yusidi  Â·  3Comments

kalvenschraut picture kalvenschraut  Â·  6Comments

fender picture fender  Â·  5Comments

ustccjw picture ustccjw  Â·  4Comments