correcting a problem with regards to accumulated event handlers in the presence of a to-draw that doesn't return a view that depends on the current view.

This commit is contained in:
Danny Yoo 2012-03-15 14:29:44 -04:00
parent 1f04418f7c
commit 45ef3b21f9
2 changed files with 18 additions and 39 deletions

View File

@ -36,6 +36,7 @@
JsEventSource.prototype = plt.baselib.heir(EventSource.prototype); JsEventSource.prototype = plt.baselib.heir(EventSource.prototype);
JsEventSource.prototype.onStart = function(_fireEvent, internalCall, k) { JsEventSource.prototype.onStart = function(_fireEvent, internalCall, k) {
var that = this; var that = this;
that.internalCall = internalCall;
setupProcedure(internalCall, setupProcedure(internalCall,
sender, sender,
function(v) { function(v) {
@ -45,12 +46,10 @@
k(); k();
}, },
function(err) { function(err) {
// FIXME: On error, silently fail?
console.log(err);
}); });
}; };
JsEventSource.prototype.onStop = function(k) { JsEventSource.prototype.onStop = function(k) {
shutdownProcedure(internalCall, shutdownProcedure(this.internalCall,
this.startupData, this.startupData,
function() { function() {
enabled = false; enabled = false;
@ -58,10 +57,6 @@
k(); k();
}, },
function(err) { function(err) {
// FIXME: On error, silently fail?
console.log(err);
enabled = false; enabled = false;
fireEvent = void(0); fireEvent = void(0);
k(); k();

View File

@ -252,9 +252,7 @@
.attr(name, value).get(0)] .attr(name, value).get(0)]
.concat(cursor.node.slice(1))); .concat(cursor.node.slice(1)));
}, },
function(eventHandlers) { function(eventHandlers) { return eventHandlers; },
return eventHandlers;
},
function(view) { function(view) {
$(view.focus).attr(name, value); $(view.focus).attr(name, value);
}); });
@ -267,9 +265,7 @@
.removeAttr(name).get(0)] .removeAttr(name).get(0)]
.concat(cursor.node.slice(1))); .concat(cursor.node.slice(1)));
}, },
function(eventHandlers) { function(eventHandlers) { return eventHandlers; },
return eventHandlers;
},
function(view) { function(view) {
$(view.focus).removeAttr(name); $(view.focus).removeAttr(name);
}); });
@ -292,9 +288,7 @@
.css(name, value).get(0)] .css(name, value).get(0)]
.concat(cursor.node.slice(1))); .concat(cursor.node.slice(1)));
}, },
function(eventHandlers) { function(eventHandlers) { return eventHandlers; },
return eventHandlers;
},
function(view) { function(view) {
$(view.focus).css(name, value); $(view.focus).css(name, value);
}); });
@ -313,9 +307,7 @@
.val(value).get(0)] .val(value).get(0)]
.concat(cursor.node.slice(1))); .concat(cursor.node.slice(1)));
}, },
function(eventHandlers) { function(eventHandlers) { return eventHandlers; },
return eventHandlers;
},
function(view) { function(view) {
$(view.focus).val(value); $(view.focus).val(value);
}); });
@ -328,9 +320,7 @@
function(cursor) { function(cursor) {
return cursor.left(); return cursor.left();
}, },
function(eventHandlers) { function(eventHandlers) { return eventHandlers; },
return eventHandlers;
},
function(view) { function(view) {
view.focus = view.focus.previousSibling; view.focus = view.focus.previousSibling;
}); });
@ -341,9 +331,7 @@
function(cursor) { function(cursor) {
return cursor.right(); return cursor.right();
}, },
function(eventHandlers) { function(eventHandlers) { return eventHandlers; },
return eventHandlers;
},
function(view) { function(view) {
view.focus = view.focus.nextSibling; view.focus = view.focus.nextSibling;
}); });
@ -354,9 +342,7 @@
function(cursor) { function(cursor) {
return cursor.up(); return cursor.up();
}, },
function(eventHandlers) { function(eventHandlers) { return eventHandlers; },
return eventHandlers;
},
function(view) { function(view) {
view.focus = view.focus.parentNode; view.focus = view.focus.parentNode;
}); });
@ -367,9 +353,7 @@
function(cursor) { function(cursor) {
return cursor.down(); return cursor.down();
}, },
function(eventHandlers) { function(eventHandlers) { return eventHandlers; },
return eventHandlers;
},
function(view) { function(view) {
view.focus = view.focus.firstChild; view.focus = view.focus.firstChild;
}); });
@ -381,9 +365,7 @@
function(cursor) { function(cursor) {
return cursor.succ(); return cursor.succ();
}, },
function(eventHandlers) { function(eventHandlers) { return eventHandlers; },
return eventHandlers;
},
function(view) { function(view) {
if (view.focus.firstChild) { if (view.focus.firstChild) {
view.focus = view.focus.firstChild; view.focus = view.focus.firstChild;
@ -406,9 +388,7 @@
function(cursor) { function(cursor) {
return cursor.pred(); return cursor.pred();
}, },
function(eventHandlers) { function(eventHandlers) { return eventHandlers; },
return eventHandlers;
},
function(view) { function(view) {
if (view.focus.previousSibling) { if (view.focus.previousSibling) {
view.focus = view.focus.previousSibling; view.focus = view.focus.previousSibling;
@ -1350,9 +1330,13 @@
} else { } else {
view.top = arrayTreeToDomNode(newMockView.getCursor().top().node); view.top = arrayTreeToDomNode(newMockView.getCursor().top().node);
view.initialRender(top); view.initialRender(top);
var oldEventHandlers = eventHandlers;
eventHandlers = newMockView.eventHandlers.slice(0); eventHandlers = newMockView.eventHandlers.slice(0);
view.eventHandlers = eventHandlers; startEventHandlers(function() {
startEventHandlers(success); eventHandlers = eventHandlers.concat(oldEventHandlers);
view.eventHandlers = eventHandlers;
success();
});
} }
}, },
function(err) { function(err) {