You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by jk...@apache.org on 2014/05/01 12:59:39 UTC

git commit: TAP5-1866: stop the ZoneRefresh timer if a Zone if removed from the DOM

Repository: tapestry-5
Updated Branches:
  refs/heads/master 6f827cb98 -> b97d9aa36


TAP5-1866: stop the ZoneRefresh timer if a Zone if removed from the DOM


Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo
Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/b97d9aa3
Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/b97d9aa3
Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/b97d9aa3

Branch: refs/heads/master
Commit: b97d9aa36a7c4826a329ebad7ca44a4067a48de9
Parents: 6f827cb
Author: Jochen Kemnade <jo...@web.de>
Authored: Thu May 1 12:32:27 2014 +0200
Committer: Jochen Kemnade <jo...@web.de>
Committed: Thu May 1 12:32:27 2014 +0200

----------------------------------------------------------------------
 .../META-INF/modules/t5/core/zone-refresh.coffee      | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/b97d9aa3/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/zone-refresh.coffee
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/zone-refresh.coffee b/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/zone-refresh.coffee
index 82c8488..4fb960f 100644
--- a/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/zone-refresh.coffee
+++ b/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/zone-refresh.coffee
@@ -36,10 +36,21 @@ define ["./events", "./dom", "./console"],
 
       zone.on events.zone.didUpdate, -> executing = false
 
+      cleanUp = ->
+        window.clearInterval intervalId
+        zone = null
+
       handler = ->
         # Don't clog things up if the response rate is too slow
         return if executing
 
+        # If the zone element is no longer part of the DOM, stop the
+        # timer
+
+        unless (zone.closest 'body')
+          cleanUp()
+          return
+
         # Set the flag now, it will clear when the zone updates.
         executing = true
 
@@ -48,8 +59,7 @@ define ["./events", "./dom", "./console"],
       intervalId = window.setInterval handler, period * 1000
 
       # Not sure if this is needed except for IE:
-      (dom window).on "beforeunload", ->
-        window.clearInterval intervalId
+      (dom window).on "beforeunload", cleanUp
 
     # export the single function:
     return initialize