blob: 190bb9c74d193ad97fcfafba512305b6f6366dcf (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
var domBatch = {};
var reads = [];
var writes = [];
var batch;
function call(fns) {
var fn;
while (fn = fns.shift()) fn();
}
domBatch.read = function(fn) {
batch = batch || setBatch();
reads.push(fn);
};
domBatch.write = function(fn) {
batch = batch || setBatch();
writes.push(fn);
};
function setBatch() {
return setTimeout(function() {
call(reads);
call(writes);
batch = null;
}, 0);
}
|