From 1666a45c6b5cf4e475ec5520d50311e63eb90926 Mon Sep 17 00:00:00 2001 From: JC Brand Date: Thu, 30 Jun 2016 14:15:05 +0200 Subject: [PATCH] Handle case where `this` of overridden method is not the pluggable due for example to it being called by an event handler. --- src/converse-pluggable.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/converse-pluggable.js b/src/converse-pluggable.js index 783ae8ad4..521c4b07d 100644 --- a/src/converse-pluggable.js +++ b/src/converse-pluggable.js @@ -27,6 +27,13 @@ * original method. */ if (typeof super_method === "function") { + if (typeof this._super === "undefined") { + // We're not on the context of the plugged object. + // This can happen when the overridden method is called via + // an event handler. In this case, we simply tack on the + // _super obj. + this._super = {}; + } this._super[key] = super_method.bind(this); } return value.apply(this, _.rest(arguments, 3));