mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-03-12 06:28:10 +00:00
MessageCatcher: Fix stack overflow when re-issuing a trapped message
This makes it possible to trap a message and then re-issue the same message within the action string without an infinite loop.
This commit is contained in:
parent
0be39cfbc2
commit
bdbb884be0
@ -36,9 +36,14 @@ MessageCatcherWidget.prototype.render = function(parent,nextSibling) {
|
|||||||
// Helper to add an event handler
|
// Helper to add an event handler
|
||||||
var addEventHandler = function(type,actions) {
|
var addEventHandler = function(type,actions) {
|
||||||
if(type && actions) {
|
if(type && actions) {
|
||||||
|
var isActionStringExecuting = false;
|
||||||
self.addEventListener(
|
self.addEventListener(
|
||||||
type,
|
type,
|
||||||
function(event) {
|
function(event) {
|
||||||
|
// Don't trap the event if it came from one of our action handlers
|
||||||
|
if(isActionStringExecuting) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
// Collect all the event properties into variables
|
// Collect all the event properties into variables
|
||||||
var collectProps = function(obj,prefix) {
|
var collectProps = function(obj,prefix) {
|
||||||
prefix = prefix || "";
|
prefix = prefix || "";
|
||||||
@ -60,7 +65,9 @@ MessageCatcherWidget.prototype.render = function(parent,nextSibling) {
|
|||||||
{
|
{
|
||||||
modifier: $tw.keyboardManager.getEventModifierKeyDescriptor(event)
|
modifier: $tw.keyboardManager.getEventModifierKeyDescriptor(event)
|
||||||
});
|
});
|
||||||
|
isActionStringExecuting = true;
|
||||||
self.invokeActionString(actions,self,event,variables);
|
self.invokeActionString(actions,self,event,variables);
|
||||||
|
isActionStringExecuting = false;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user