incorrect ponyfill for replaceAll()
See original GitHub issueHi! I was experimenting with replaceAll()
from ramda adjunct version 2.27.0
and found the internal ponyfill has some inconsistencies with the native browser version.
Here is the code I tried in both browser and runkit:
// browser version:
'foo.bar'.replaceAll('.', '$$$$$') // prints 'foo$$$bar' in Chrome 85, Windows 7
// runkit version:
RA.replaceAll('.', '$$$$$', 'foo.bar') // prints 'foo$$$$$bar'
( runkit code can be seen here: https://runkit.com/embed/xb4qhttrwooh )
It turns out, that the new implementation of String.prototype.replace()
has a few special character patterns, that are handled differently as one would expect – for example $$
is turned into $
– and String.prototype.replaceAll()
inherits this behavior.
https://tc39.es/ecma262/#table-replacement-text-symbol-substitutions
Please update https://github.com/char0n/ramda-adjunct/blob/master/src/internal/ponyfills/String.replaceAll.js to include these special patterns, or have a standalone implementation of replaceAll without using String.prototype.replaceAll()
, even if it’s accessible.
Thanks in advance!
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (2 by maintainers)
Top GitHub Comments
@char0n this sounds reasonable, I think we should go this way
Thank you!