Ticket #723 (closed defect: fixed)
WordPress.com Stats pollute the js namespace - fix proposal
| Reported by: | gonchuki | Owned by: | andy |
|---|---|---|---|
| Priority: | normal | Component: | stats |
| Severity: | major | Keywords: | stats, mootools, clash, javascript, conflict |
| Cc: |
Description
note: previously posted this on wp.org public forum and they directed me to here. I'm opening the ticket here with a little reworded version of the issue as I took a look over the implementation.
I just got struck by an ugly implementation in the wordpress.com Stats plugin that deliberately adds functions to the global namespace polluting it and clashing against mootools on the addEvent function, thus breaking the library at least under IE, Safari and Opera (Gecko-based browsers natively implement addEventListener and don't get the method redefined).
For sanity and future proofness, I would suggest you to encapsulate your functions in a private namespace, as you are not only colliding with mootools, but also any other library out there implementing an addEvent function in the global namespace (DOM Assistant comes to mind right now, there may be more)
FWIW I coudn't find the js code in the repository, but I got my hands on the generated code by sniffing the requests under IE. As I see it, it should be simple to solve and I will be submitting a patch as soon as I can (I'm getting horrid errors in my blog and need it fixed ASAP). I will just ask to whoever manages the js file to accept my fixes and upload/commit it to the http://stats.wordpress.com server.

