SwitchNode: allow use of properties beneath the top level

This commit is contained in:
Nicholas O'Leary 2013-10-19 21:04:17 +01:00
parent 547ae0cd72
commit f8e8bf22c0
1 changed files with 6 additions and 2 deletions

View File

@ -39,14 +39,18 @@ function SwitchNode(n) {
this.rules = n.rules;
this.property = n.property;
var propertyParts = n.property.split(".");
var node = this;
this.on('input',function(msg) {
var onward = [];
var prop = propertyParts.reduce(function(obj,i) {
return obj[i]
},msg);
for (var i=0;i<node.rules.length;i+=1) {
var rule = node.rules[i];
if (operators[rule.t](msg[node.property],rule.v,rule.v2)) {
if (operators[rule.t](prop,rule.v,rule.v2)) {
onward.push(msg);
} else {
onward.push(null);