From 26a34ae1fd144ecff05c66abb94da09b20a71fce Mon Sep 17 00:00:00 2001 From: Danny Yoo Date: Mon, 12 Sep 2011 13:16:10 -0400 Subject: [PATCH] still chasing bug --- .../forward-backward/forward-backward.rkt | 33 ++++++++++++------- web-world/js-impl.js | 5 ++- 2 files changed, 23 insertions(+), 15 deletions(-) diff --git a/web-world/examples/forward-backward/forward-backward.rkt b/web-world/examples/forward-backward/forward-backward.rkt index 17b2040..c1fbc92 100644 --- a/web-world/examples/forward-backward/forward-backward.rkt +++ b/web-world/examples/forward-backward/forward-backward.rkt @@ -11,26 +11,35 @@ (define (go-backward world dom) (max (sub1 world) 0)) +(define (view-top a-view) + (if (view-up? a-view) + (view-top (view-up a-view)) + a-view)) + (define (clear-all a-view) - (define updated-view (update-view-css a-view "border" "none")) - (cond - [(view-forward? updated-view) - (clear-all (view-forward updated-view))] - [else - updated-view])) + (define (loop a-view n) + (define updated-view (update-view-css a-view "border" "none")) + (cond + [(view-forward? updated-view) + (loop (view-forward updated-view) (add1 n))] + [else + (view-top updated-view)])) + (loop a-view 0)) (define (iterate n f x) (if (<= n 0) x - (iterate (sub1 n ) f (f x)))) + (iterate (sub1 n) f (f x)))) (define (draw world dom) - (update-view-css (iterate world - view-forward - (clear-all dom)) - "border" - "1px solid blue")) + (define another-view (update-view-css (iterate world + view-forward + (clear-all dom)) + "border" + "1px solid blue")) + another-view) + (define my-initial-view (view-bind (view-focus diff --git a/web-world/js-impl.js b/web-world/js-impl.js index d2a11e1..d6aac71 100644 --- a/web-world/js-impl.js +++ b/web-world/js-impl.js @@ -340,7 +340,7 @@ } else if (view.focus.next().length > 0) { view.focus = view.focus.next(); } else { - while (true) { + while (view.focus.get(0) !== view.top.get(0)) { view.focus = view.focus.parent(); if (view.focus.next().length > 0) { view.focus = view.focus.next(); @@ -349,7 +349,7 @@ } } }); - }; +}; MockView.prototype.backward = function() { return this.act( @@ -593,7 +593,6 @@ View.prototype.getMockAndResetFocus = function(nonce) { this.focus = this.top; - return new MockView(domToArrayTreeCursor($(this.top).get(0)), EMPTY_PENDING_ACTIONS, this.eventHandlers.slice(0),