diff options
author | Wilson Page <wilsonpage@me.com> | 2013-08-26 22:26:18 +0100 |
---|---|---|
committer | Wilson Page <wilsonpage@me.com> | 2013-08-26 22:28:23 +0100 |
commit | a8df943ef4b842a3bbc5a65c70a3a3ef50445fa5 (patch) | |
tree | f000c35cc6add29eae2eb3ba77ee8546126497fd /lib/dom-batch.js | |
parent | 648e085853505e542826feab1fa71e43c37f7ee0 (diff) | |
download | fastdom-a8df943ef4b842a3bbc5a65c70a3a3ef50445fa5.zip fastdom-a8df943ef4b842a3bbc5a65c70a3a3ef50445fa5.tar.gz fastdom-a8df943ef4b842a3bbc5a65c70a3a3ef50445fa5.tar.bz2 |
DomBatch should return instantiated version so it is shared across modules by default
Diffstat (limited to 'lib/dom-batch.js')
-rw-r--r-- | lib/dom-batch.js | 17 |
1 files changed, 12 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 |