# HG changeset patch # User Sonny Piers # Date 1328107617 -3600 # Node ID 1d4b844586f6a672805a63f0d058934b78fdadf4 # Parent aaad98b33f860988812021dee3fdbacf6d326718 Bind methods so Lightstring.Connection.plugin.method works with the correct context. diff --git a/lightstring.js b/lightstring.js --- a/lightstring.js +++ b/lightstring.js @@ -391,17 +391,23 @@ Lightstring.Connection.prototype = { var plugin = Lightstring.plugins[name]; + //Namespaces for (var ns in plugin.namespaces) Lightstring.ns[ns] = plugin.namespaces[ns]; + //Stanzas Lightstring.stanzas[name] = {}; for (var stanza in plugin.stanzas) Lightstring.stanzas[name][stanza] = plugin.stanzas[stanza]; + //Handlers for (var handler in plugin.handlers) this.on(handler, plugin.handlers[handler]); - this[name] = plugin.methods; + //Methods + this[name] = {}: + for (var method in plugins.methods) + this[name][method].bind(this); if (plugin.init) plugin.init();