bestiejs / json3

A JSON polyfill. No longer maintained.
https://bestiejs.github.io/json3
Other
1.02k stars 150 forks source link

Enhance `noConflict` to restore previous `JSON3` object #56

Closed jstayton closed 10 years ago

jstayton commented 10 years ago

Hey there,

I'm using JSON3 as a dependency in a browser-based third-party JS library. My goal is to prevent potential conflicts as much as possible, so noConflict has come in handy. Thanks!

One enhancement that I'd like your feedback on is taking noConflict one step further and restoring the global JSON3 object that's exposed to the previous value. This way, if the page including my library already uses an older/newer version of JSON3, there's no chance for potential conflict. (Duh, you all probably don't need that explained. :smile:)

What do you think? I may try adding this enhancement if you're cool with the idea.

Thanks again for your work on this!

ghost commented 10 years ago

I like that. jQuery's noConflict() function accepts a removeAll flag that restores both $ and jQuery to their previous values...but, in our case, I think we can just restore both values automatically.

jstayton commented 10 years ago

Great! I couldn't have asked for a quicker turn-around on that. Thanks, @kitcambridge!

bnjmnt4n commented 10 years ago

I will close this for now.