matchAll Polyfill
See original GitHub issueWe’ve been seeing some client side error logs re .matchAll()
calls evaluating to undefined
. After a bit of digging, we realized that all of those exceptions originate on older-ish browsers. Nonetheless, this is an issue for us (and I suspect others, too). Specifically, the issue stems from this line: https://github.com/dcastil/tailwind-merge/blob/a703309b6811b8b798b1a8cd2d1db3ac06811b36/src/lib/merge-classlist.ts#L83
I’m curious if you’ve given thought to adding a matchAll polyfill, or using a different approach to matching?
Issue Analytics
- State:
- Created a year ago
- Comments:8 (3 by maintainers)
Top Results From Across the Web
How to use the string.prototype.matchall polyfill?
I used this, works for me. Looping through the matches of global flagged pattern did the trick. Let me know if you have...
Read more >A polyfill for the String.prototype.matchAll method ... - GitHub Gist
A polyfill for the String.prototype.matchAll method. Only available in Node12+ and most browsers. - matchAll polyfill.js.
Read more >string.prototype.matchall - npm
Spec-compliant polyfill for String.prototype.matchAll. Latest version: 4.0.8, last published: a month ago.
Read more >String.prototype.matchAll() - JavaScript - MDN Web Docs
The matchAll() method returns an iterator of all results matching a string against a regular expression, including capturing groups.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Confirmed working on latest v1.6.0. Thanks so much, @dcastil !
Right – I’ve impl’d that polyfill and it seems to work for us. But it took us an hour to realize this was the issue. Figured I’d post here to save others some time.
I’m able to reproduce this on Chrome 70.x on Mac. It’s difficult to run multiple Chrome versions on the same machine, but you can download an old build of Chromium and easily run that side-by-side. Here’s the version I’m using: version: 70.0.3538.124
Here’s a sample stacktrace, although, the issue is rather straight forward: