summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilson Page <wilsonpage@me.com>2013-02-11 09:59:49 +0000
committerWilson Page <wilsonpage@me.com>2013-02-11 09:59:49 +0000
commit2149655a72d2da6a6a64faa10d3818418c2284a5 (patch)
treee6ecf774f272a1f9bcaab7b99cffe350e1eaa0cb
parent9d214255449b7b61b5c6bf16219fa6bfd0926043 (diff)
downloadfastdom-origin/0.2.zip
fastdom-origin/0.2.tar.gz
fastdom-origin/0.2.tar.bz2
COnvert tabs to spacesorigin/0.2
-rw-r--r--examples/index.html66
-rw-r--r--lib/dombatcher.js22
2 files changed, 43 insertions, 45 deletions
diff --git a/examples/index.html b/examples/index.html
index 9424377..1b5c237 100644
--- a/examples/index.html
+++ b/examples/index.html
@@ -10,50 +10,48 @@
</style>
</head>
<body>
- <div class='div1'></div>
- <div class='div2'></div>
- <div class='div3'></div>
- <script type="text/javascript" src="../lib/dombatcher.js"></script>
- <script>
+ <div class='div1'></div>
+ <div class='div2'></div>
+ <div class='div3'></div>
+ <script type="text/javascript" src="../lib/dombatcher.js"></script>
+ <script>
+ domBatch.write(function() {
+ console.log('write1');
+ });
+ domBatch.read(function() {
+ console.log('read1');
+ });
- domBatch.write(function() {
- console.log('write1');
- });
+ domBatch.read(function() {
+ console.log('read1');
+ });
- domBatch.read(function() {
- console.log('read1');
- });
+ domBatch.write(function() {
+ console.log('write1');
+ });
- domBatch.read(function() {
- console.log('read1');
- });
- domBatch.write(function() {
- console.log('write1');
- });
+ setTimeout(function() {
+ domBatch.write(function() {
+ console.log('write2');
+ });
- setTimeout(function() {
+ domBatch.read(function() {
+ console.log('read2');
+ });
- domBatch.write(function() {
- console.log('write2');
- });
+ domBatch.read(function() {
+ console.log('read2');
+ });
- domBatch.read(function() {
- console.log('read2');
- });
-
- domBatch.read(function() {
- console.log('read2');
- });
-
- domBatch.write(function() {
- console.log('write2');
- });
- }, 400);
- </script>
+ domBatch.write(function() {
+ console.log('write2');
+ });
+ }, 400);
+ </script>
</body>
</html> \ No newline at end of file
diff --git a/lib/dombatcher.js b/lib/dombatcher.js
index 07cba1a..190bb9c 100644
--- a/lib/dombatcher.js
+++ b/lib/dombatcher.js
@@ -6,24 +6,24 @@ var batch;
function call(fns) {
- var fn;
- while (fn = fns.shift()) fn();
+ var fn;
+ while (fn = fns.shift()) fn();
}
domBatch.read = function(fn) {
- batch = batch || setBatch();
- reads.push(fn);
+ batch = batch || setBatch();
+ reads.push(fn);
};
domBatch.write = function(fn) {
- batch = batch || setBatch();
- writes.push(fn);
+ batch = batch || setBatch();
+ writes.push(fn);
};
function setBatch() {
- return setTimeout(function() {
- call(reads);
- call(writes);
- batch = null;
- }, 0);
+ return setTimeout(function() {
+ call(reads);
+ call(writes);
+ batch = null;
+ }, 0);
} \ No newline at end of file