[extensions-web] js: Don't possibly error out when an extension changes state



commit 88a24b2fcfcc48dadfbf667c8a4057778710daff
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Sun Dec 18 04:16:59 2011 -0500

    js: Don't possibly error out when an extension changes state
    
    If we're displaying the details page of an extension and a different,
    unrelated extension changes state, we'll get an error when trying to
    trigger the 'state-changed' event. Instead, make sure that the extension
    element exists before trying to trigger the event.

 sweettooth/static/js/extensions.js |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
---
diff --git a/sweettooth/static/js/extensions.js b/sweettooth/static/js/extensions.js
index 7ee8fb6..74364ca 100644
--- a/sweettooth/static/js/extensions.js
+++ b/sweettooth/static/js/extensions.js
@@ -84,7 +84,8 @@ function($, messages, dbusProxy, extensionUtils) {
     var elems = {};
 
     dbusProxy.extensionStateChangedHandler = function(uuid, newState, _) {
-        elems[uuid].trigger('state-changed', newState);
+        if (elems[uuid] !== undefined)
+            elems[uuid].trigger('state-changed', newState);
     };
 
     function addExtensionSwitch(uuid, extension, $elem) {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]