summaryrefslogtreecommitdiffstats
path: root/lib/handlebars/compiler/visitor.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/handlebars/compiler/visitor.js')
-rw-r--r--lib/handlebars/compiler/visitor.js10
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/handlebars/compiler/visitor.js b/lib/handlebars/compiler/visitor.js
index 47f86e0..89dd632 100644
--- a/lib/handlebars/compiler/visitor.js
+++ b/lib/handlebars/compiler/visitor.js
@@ -12,8 +12,9 @@ Visitor.prototype = {
acceptKey: function(node, name) {
let value = this.accept(node[name]);
if (this.mutating) {
- // Hacky sanity check:
- if (value && typeof value.type !== 'string') {
+ // Hacky sanity check: This may have a few false positives for type for the helper
+ // methods but will generally do the right thing without a lot of overhead.
+ if (value && !Visitor.prototype[value.type]) {
throw new Exception('Unexpected node type "' + value.type + '" found when accepting ' + name + ' on ' + node.type);
}
node[name] = value;
@@ -49,6 +50,11 @@ Visitor.prototype = {
return;
}
+ /* istanbul ignore next: Sanity code */
+ if (!this[object.type]) {
+ throw new Exception('Unknown type: ' + object.type, object);
+ }
+
if (this.current) {
this.parents.unshift(this.current);
}