Skip to content

Commit

Permalink
Don't use instanceof to determine if a Context is a Context
Browse files Browse the repository at this point in the history
  • Loading branch information
sethkinast committed Sep 10, 2016
1 parent dc1e1dc commit 2ec6173
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/dust.js
Original file line number Diff line number Diff line change
Expand Up @@ -328,12 +328,17 @@
this.options = options;
this.blocks = blocks;
this.templateName = templateName;
this._isContext = true;
}

dust.makeBase = dust.context = function(global, options) {
return new Context(undefined, global, options);
};

dust.isContext = function(obj) {
return typeof obj === "object" && obj._isContext === true;
}

/**
* Factory function that creates a closure scope around a Thenable-callback.
* Returns a function that can be passed to a Thenable that will resume a
Expand All @@ -347,8 +352,7 @@
}

Context.wrap = function(context, name) {
if (context instanceof Context) {
context.templateName = name;
if (dust.isContext(context)) {
return context;
}
return new Context(context, {}, {}, null, name);
Expand Down

0 comments on commit 2ec6173

Please sign in to comment.