Tidying up the Change node after a lot of churn

This commit is contained in:
Nick O'Leary
2013-12-24 23:16:36 +00:00
parent 74f43f4059
commit 24c373ecc2
2 changed files with 6 additions and 8 deletions

View File

@@ -24,7 +24,9 @@ function ChangeNode(n) {
this.to = n.to || " ";
this.reg = (n.reg === null || n.reg);
var node = this;
if (node.reg === false) {
this.from = this.from.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
}
var makeNew = function( stem, path, value ) {
var lastPart = (arguments.length === 3) ? path.pop() : false;
for (var i = 0; i < path.length; i++) {
@@ -36,12 +38,8 @@ function ChangeNode(n) {
this.on('input', function (msg) {
if (node.action == "change") {
var from = node.from;
if (node.reg === false) {
from = from.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
}
try {
node.re = new RegExp(from, "g");
node.re = new RegExp(this.from, "g");
} catch (e) {
node.error(e.message);
}