Commit 82107c0d authored by JC Brand's avatar JC Brand

Don't ever remove the _super obj

parent e87731f6
...@@ -2056,20 +2056,14 @@ ...@@ -2056,20 +2056,14 @@
return this; return this;
}; };
this.wrappedOverride = function (key, value, super_method, clean) { this.wrappedOverride = function (key, value, super_method) {
// We create a partially applied wrapper function, that // We create a partially applied wrapper function, that
// makes sure to set the proper super method when the // makes sure to set the proper super method when the
// overriding method is called. This is done to enable // overriding method is called. This is done to enable
// chaining of plugin methods, all the way up to the // chaining of plugin methods, all the way up to the
// original method. // original method.
var ret;
if (clean) {
converse._super = { 'converse': converse };
}
this._super[key] = super_method; this._super[key] = super_method;
ret = value.apply(this, _.rest(arguments, 4)); return value.apply(this, _.rest(arguments, 3));
if (clean) { delete this._super; }
return ret;
}; };
this._overrideAttribute = function (key, plugin) { this._overrideAttribute = function (key, plugin) {
...@@ -2078,7 +2072,7 @@ ...@@ -2078,7 +2072,7 @@
if (typeof value === "function") { if (typeof value === "function") {
var wrapped_function = _.partial( var wrapped_function = _.partial(
converse.wrappedOverride.bind(converse), converse.wrappedOverride.bind(converse),
key, value, converse[key].bind(converse), true key, value, converse[key].bind(converse)
); );
converse[key] = wrapped_function; converse[key] = wrapped_function;
} else { } else {
...@@ -2102,7 +2096,7 @@ ...@@ -2102,7 +2096,7 @@
// original method. // original method.
var wrapped_function = _.partial( var wrapped_function = _.partial(
converse.wrappedOverride, converse.wrappedOverride,
key, value, obj.prototype[key], false key, value, obj.prototype[key]
); );
obj.prototype[key] = wrapped_function; obj.prototype[key] = wrapped_function;
} else { } else {
...@@ -2112,6 +2106,9 @@ ...@@ -2112,6 +2106,9 @@
}; };
this.initializePlugins = function () { this.initializePlugins = function () {
if (typeof converse._super === 'undefined') {
converse._super = { 'converse': converse };
}
var updateSettings = function (settings) { var updateSettings = function (settings) {
/* Helper method which gets put on the plugin and allows it to /* Helper method which gets put on the plugin and allows it to
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment