summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/dom-batch.js17
-rw-r--r--test/tests.js1
2 files changed, 13 insertions, 5 deletions
diff --git a/lib/dom-batch.js b/lib/dom-batch.js
index 4671b80..f4124ce 100644
--- a/lib/dom-batch.js
+++ b/lib/dom-batch.js
@@ -9,7 +9,7 @@
* @author Wilson Page <wilsonpage@me.com>
*/
-;(function(){
+;(function(dom){
'use strict';
@@ -19,6 +19,13 @@
|| window.mozRequestAnimationFrame
|| function(cb) { window.setTimeout(cb, 1000 / 60); };
+ // Use existing instance if
+ // one already exists in
+ // this app, else make one.
+ dom = (dom instanceof DomBatch)
+ ? dom
+ : new DomBatch();
+
/**
* Creates a new
* DomBatch instance.
@@ -143,11 +150,11 @@
*/
if (typeof exports === "object") {
- module.exports = DomBatch;
+ module.exports = dom;
} else if (typeof define === "function" && define.amd) {
- define(function(){ return DomBatch; });
+ define(function(){ return dom; });
} else {
- window['DomBatch'] = DomBatch;
+ window['dom'] = dom;
}
-})();
+})(window.dom); \ No newline at end of file
diff --git a/test/tests.js b/test/tests.js
index bc708b4..09f4b25 100644
--- a/test/tests.js
+++ b/test/tests.js
@@ -1,3 +1,4 @@
+var DomBatch = dom.constructor;
buster.testCase('DomBatch', {