From 31d1137143ed8bbadf67551f416850b7fdc21fbd Mon Sep 17 00:00:00 2001 From: Michael Brade Date: Tue, 29 Sep 2015 18:34:31 -0700 Subject: [PATCH] FnExpressions: actually check that it is a function we are about to call --- lib/expressions.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/expressions.js b/lib/expressions.js index e61344e..05942c2 100644 --- a/lib/expressions.js +++ b/lib/expressions.js @@ -408,20 +408,20 @@ FnExpression.prototype._lookupParent = function(context) { // Lookup function in the model var segments = this.parentSegments; var parent = (segments) ? lookup(segments, context.controller.model.data) : undefined; - if (parent && parent[this.lastSegment]) return parent; - // Lookup function on current controller + if (parent && typeof parent[this.lastSegment] == 'function') return parent; + // Otherwise lookup function on current controller var controller = context.controller; parent = (segments) ? lookup(segments, controller) : controller; - if (parent && parent[this.lastSegment]) return parent; + if (parent && typeof parent[this.lastSegment] == 'function') return parent; // Otherwise lookup function on page var page = controller.page; if (controller !== page) { parent = (segments) ? lookup(segments, page) : page; - if (parent && parent[this.lastSegment]) return parent; + if (parent && typeof parent[this.lastSegment] == 'function') return parent; } // Otherwise lookup function on global parent = (segments) ? lookup(segments, global) : global; - if (parent && parent[this.lastSegment]) return parent; + if (parent && typeof parent[this.lastSegment] == 'function') return parent; // Throw if not found throw new Error('Function not found for: ' + this.segments.join('.')); };