Browse Source

Improved spine stopListeningTo() - In certain cases (e. g. http://localhost:3000/#knowledge_base/1/locale/en-us/edit just change the title and submit) a `Uncaught TypeError: Cannot read property 'obj' of undefined` is raised. The reason is that listeningToOnce is an empty array.

Martin Edenhofer 5 years ago
parent
commit
049adbe469
1 changed files with 6 additions and 0 deletions
  1. 6 0
      app/assets/javascripts/app/lib/spine/spine.coffee

+ 6 - 0
app/assets/javascripts/app/lib/spine/spine.coffee

@@ -60,6 +60,12 @@ Events =
         for ev in events
           for idx in [listeningTo.length-1..0]
             lt = listeningTo[idx]
+            # 2019-05-20 (me): check if listeningTo has content
+            # in certain cases (e. g. http://localhost:3000/#knowledge_base/1/locale/en-us/edit just
+            # change the title and submit) a `Uncaught TypeError: Cannot read property 'obj' of undefined`
+            # is raised. The reason is that listeningToOnce is an empty array.
+            continue if !lt
+            # /2019-05-20 (me)
             continue unless lt.obj is obj
             continue if callback and lt.callback isnt callback
             if (not ev) or (ev is lt.ev)