summaryrefslogtreecommitdiff
path: root/couchjs/js/util.js
diff options
context:
space:
mode:
authorAdam Kocoloski <adam@cloudant.com>2011-10-04 13:11:12 -0700
committerAdam Kocoloski <adam@cloudant.com>2011-10-04 13:11:12 -0700
commitda7284ed2844926c7df0efef12ba30d8e2e6d039 (patch)
tree10fa2d5cf35bfae4d48fc632924cec98ee02a22a /couchjs/js/util.js
parentb57aadd742e4f8cc925ba4f005ae658c43a7c5b4 (diff)
parent4e19639a64d3033e1cc7c22a0b7404d277643c78 (diff)
Merge pull request #67 from cloudant/12645-merge_latest_1.1.x
Diffstat (limited to 'couchjs/js/util.js')
-rw-r--r--couchjs/js/util.js11
1 files changed, 8 insertions, 3 deletions
diff --git a/couchjs/js/util.js b/couchjs/js/util.js
index e4386701..d498ee64 100644
--- a/couchjs/js/util.js
+++ b/couchjs/js/util.js
@@ -46,7 +46,7 @@ var resolveModule = function(names, mod, root) {
} else if (root) {
mod = {current : root};
}
- if (!mod.current[n]) {
+ if (mod.current[n] === undefined) {
throw ["error", "invalid_require_path", 'Object has no property "'+n+'". '+JSON.stringify(mod.current)];
}
return resolveModule(names, {
@@ -63,6 +63,11 @@ var Couch = {
},
compileFunction : function(source, ddoc) {
if (!source) throw(["error","not_found","missing function"]);
+ // Some newer SpiderMonkey's appear to not like evaluating
+ // an anonymous function at global scope. Simple fix just
+ // wraps the source with parens so the function object is
+ // returned correctly.
+ source = "(" + source + ")";
try {
if (sandbox) {
if (ddoc) {
@@ -91,9 +96,9 @@ var Couch = {
}
sandbox.require = require;
}
- var functionObject = evalcx(source, sandbox);
+ var functionObject = evalcx("(" + source + ")", sandbox);
} else {
- var functionObject = eval(source);
+ var functionObject = eval("(" + source + ")");
}
} catch (err) {
throw(["error", "compilation_error", err.toSource() + " (" + source + ")"]);