mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-02-25 14:45:45 +01:00
Prevent infinite loops when trying to execute mappings recursively.
This commit is contained in:
@@ -1018,6 +1018,7 @@ var Events = Module("events", {
|
|||||||
if (refeed)
|
if (refeed)
|
||||||
for (let [i, event] in Iterator(refeed))
|
for (let [i, event] in Iterator(refeed))
|
||||||
if (event.originalTarget) {
|
if (event.originalTarget) {
|
||||||
|
util.dump("Re-feed " + i + " " + refeed.length + " " + (events.toString(event) || "").quote());
|
||||||
let evt = events.create(event.originalTarget.ownerDocument, event.type, event);
|
let evt = events.create(event.originalTarget.ownerDocument, event.type, event);
|
||||||
events.dispatch(event.originalTarget, evt, i == 0 && { skipmap: true });
|
events.dispatch(event.originalTarget, evt, i == 0 && { skipmap: true });
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -110,7 +110,11 @@ var Map = Class("Map", {
|
|||||||
if (this.names[0] != ".") // FIXME: Kludge.
|
if (this.names[0] != ".") // FIXME: Kludge.
|
||||||
mappings.repeat = repeat;
|
mappings.repeat = repeat;
|
||||||
|
|
||||||
return dactyl.trapErrors(repeat);
|
dactyl.assert(!this.executing, "Attempt to execute mapping recursively");
|
||||||
|
this.executing = true;
|
||||||
|
let res = dactyl.trapErrors(repeat);
|
||||||
|
this.executing = false;
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
}, {
|
}, {
|
||||||
|
|||||||
@@ -387,7 +387,7 @@ var Modes = Module("modes", {
|
|||||||
}, options);
|
}, options);
|
||||||
},
|
},
|
||||||
|
|
||||||
toString: function () this.name,
|
get toStringParams() [this.name],
|
||||||
|
|
||||||
valueOf: function () this.id,
|
valueOf: function () this.id,
|
||||||
|
|
||||||
@@ -411,14 +411,14 @@ var Modes = Module("modes", {
|
|||||||
}),
|
}),
|
||||||
StackElement: (function () {
|
StackElement: (function () {
|
||||||
const StackElement = Struct("main", "extended", "params", "saved");
|
const StackElement = Struct("main", "extended", "params", "saved");
|
||||||
|
StackElement.className = "Modes.StackElement";
|
||||||
StackElement.defaultValue("params", function () this.main.params);
|
StackElement.defaultValue("params", function () this.main.params);
|
||||||
|
|
||||||
update(StackElement.prototype, {
|
update(StackElement.prototype, {
|
||||||
toString: function () !loaded.modes ? this.main : "[mode " +
|
get toStringParams() !loaded.modes ? this.main.name : [
|
||||||
this.main.name +
|
this.main.name,
|
||||||
(!this.extended ? "" :
|
<>({ modes.all.filter(function (m) this.extended & m, this).map(function (m) m.name).join("|") })</>
|
||||||
"(" + modes.all.filter(function (m) this.extended & m)
|
]
|
||||||
.join("|") +
|
|
||||||
")") + "]"
|
|
||||||
});
|
});
|
||||||
return StackElement;
|
return StackElement;
|
||||||
})(),
|
})(),
|
||||||
|
|||||||
@@ -769,7 +769,8 @@ Class.prototype = {
|
|||||||
toString: function () {
|
toString: function () {
|
||||||
if (this.toStringParams)
|
if (this.toStringParams)
|
||||||
var params = "(" + this.toStringParams.map(function (m) isArray(m) ? "[" + m + "]" :
|
var params = "(" + this.toStringParams.map(function (m) isArray(m) ? "[" + m + "]" :
|
||||||
isString(m) ? m.quote() : String(m)) + ")";
|
isString(m) ? m.quote() : String(m))
|
||||||
|
.join(", ") + ")";
|
||||||
return "[instance " + this.constructor.className + (params || "") + "]";
|
return "[instance " + this.constructor.className + (params || "") + "]";
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user