summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilson Page <wilsonpage@me.com>2013-10-14 17:32:22 +0100
committerWilson Page <wilsonpage@me.com>2013-10-14 17:32:22 +0100
commitc75e18d10d990f071924c87932519f26618f2458 (patch)
treec3e83ae2722eaedc26cd323453c3a647ac19c4e5
parent0feba0fbc5c8143600bfa7ac8582be904f0753a1 (diff)
downloadfastdom-c75e18d10d990f071924c87932519f26618f2458.zip
fastdom-c75e18d10d990f071924c87932519f26618f2458.tar.gz
fastdom-c75e18d10d990f071924c87932519f26618f2458.tar.bz2
Not quiet by default
-rw-r--r--index.js17
-rw-r--r--test/test.set.js19
2 files changed, 18 insertions, 18 deletions
diff --git a/index.js b/index.js
index 337bc80..feafcad 100644
--- a/index.js
+++ b/index.js
@@ -266,9 +266,10 @@
// Clear reference to the job
delete this.queue.hash[job.id];
- // Call the job in
- try { job.fn.call(ctx); } catch(e) {
- this.onError(e);
+ if (this.quiet) {
+ try { job.fn.call(ctx); } catch (e) {}
+ } else {
+ job.fn.call(ctx);
}
};
@@ -332,16 +333,6 @@
return this.frames[index] = fn;
};
- /**
- * Called when a callback errors.
- * Overwrite this if you don't
- * want errors inside your jobs
- * to fail silently.
- *
- * @param {Error}
- */
- FastDom.prototype.onError = function(){};
-
// We only ever want there to be
// one instance of FastDom in an app
fastdom = fastdom || new FastDom();
diff --git a/test/test.set.js b/test/test.set.js
index 3b6cb86..f5b2ae3 100644
--- a/test/test.set.js
+++ b/test/test.set.js
@@ -59,11 +59,17 @@ suite('set', function() {
assert(!cb.called);
done();
});
+
+ // Should not have scheduled a new frame
+ assert(fastdom.frames.length === 0);
});
});
test('Should call a write in the same frame if scheduled inside a read callback', function(done) {
var fastdom = new FastDom();
+
+ fastdom.catchErrors = false;
+
var cb = sinon.spy();
fastdom.read(function() {
@@ -80,6 +86,9 @@ suite('set', function() {
assert(!cb.called);
done();
});
+
+ // Should not have scheduled a new frame
+ assert(fastdom.frames.length === 0);
});
});
@@ -100,6 +109,9 @@ suite('set', function() {
assert(cb.called);
done();
});
+
+ // Should not have scheduled a new frame
+ assert(fastdom.frames.length === 1);
});
});
@@ -162,12 +174,12 @@ suite('set', function() {
});
});
- test('Should call a registered onError handler when an error is thrown inside a job', function(done) {
+ test('Should no error if the `quiet` flag is set', function(done) {
var fastdom = new FastDom();
var err1 = { some: 'error1' };
var err2 = { some: 'error2' };
- fastdom.onError = sinon.spy();
+ fastdom.quiet = true;
fastdom.read(function() {
throw err1;
@@ -178,9 +190,6 @@ suite('set', function() {
});
raf(function() {
- assert(fastdom.onError.calledTwice);
- assert(fastdom.onError.getCall(0).calledWith(err1));
- assert(fastdom.onError.getCall(1).calledWith(err2));
done();
});
});