From: Dmitry Baranovskiy Date: Thu, 18 Jun 2009 05:25:17 +0000 (+1000) Subject: Fixed plugins. X-Git-Tag: semver~60 X-Git-Url: http://git.roojs.org/?p=raphael;a=commitdiff_plain;h=47addb3c33635c25cc26ee48faa2ee670834af2a Fixed plugins. --- diff --git a/raphael.js b/raphael.js index 2faddf4..7af45c8 100644 --- a/raphael.js +++ b/raphael.js @@ -591,21 +591,24 @@ window.Raphael = (function () { } }, plugins = function (con, add) { - for (var prop in add) if (add.hasOwnProperty(prop) && !(prop in con)) { - switch (typeof add[prop]) { - case "function": - con[prop] = con === this ? add[prop] : function () { return add[prop].apply(this, arguments); }; - break; - case "object": - con[prop] = {}; - plugins.call(this, con[prop], add[prop]); - break; - default: - con[prop] = add[prop]; - break; + var that = this; + for (var prop in add) if (add.hasOwnProperty(prop) && !(prop in con)) { + switch (typeof add[prop]) { + case "function": + (function (f) { + con[prop] = con === that ? f : function () { return f.apply(that, arguments); }; + })(add[prop]); + break; + case "object": + con[prop] = con[prop] || {}; + plugins.call(this, con[prop], add[prop]); + break; + default: + con[prop] = add[prop]; + break; + } } - } - }; + }; // SVG if (R.svg) {