ScottHamper / Cookies

JavaScript Client-Side Cookie Manipulation Library
The Unlicense
1.77k stars 169 forks source link

avoid pass native function to string.replace #27

Closed sunteya closed 10 years ago

sunteya commented 10 years ago

I use the cookies-js in a STB project. It contains an old and quirky browser(called ipanel).

If use string.replace and pass native function, it will like this:

var a = "12345".replace(/4/, encodeURIComponent);
alert(a); // print 123encodeURIComponent(){ [native code]}5

It must wrap the native function.

var a = "12345".replace(/4/,function(s) { return encodeURIComponent(s) });
alert(a); // print 12345
ScottHamper commented 10 years ago

Hey Sunteya,

I've been conflicted about this pull request for a long time. On one hand, the change you've provided is a very small change, and would allow Cookies.js to work in another browser. On the other hand, ipanel is not a browser I am particularly interested in supporting, especially since doing so would require a less elegant implementation.

In the end, I have decided not to merge this pull request - supporting the ipanel browser is just not a priority for the project.

I apologize for any inconvenience this may cause you, but thank you so much for taking a look at the library and offering to contribute!