OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright (c) 2014 The Polymer Project Authors. All rights reserved. |
| 3 * This code may only be used under the BSD style license found at http://polyme
r.github.io/LICENSE.txt |
| 4 * The complete set of authors may be found at http://polymer.github.io/AUTHORS.
txt |
| 5 * The complete set of contributors may be found at http://polymer.github.io/CON
TRIBUTORS.txt |
| 6 * Code distributed by Google as part of the polymer project is also |
| 7 * subject to an additional IP rights grant found at http://polymer.github.io/PA
TENTS.txt |
| 8 */ |
| 9 |
| 10 (function(scope) { |
| 11 |
| 12 var iterations = 0; |
| 13 var callbacks = []; |
| 14 var twiddle = document.createTextNode(''); |
| 15 |
| 16 function endOfMicrotask(callback) { |
| 17 twiddle.textContent = iterations++; |
| 18 callbacks.push(callback); |
| 19 } |
| 20 |
| 21 function atEndOfMicrotask() { |
| 22 while (callbacks.length) { |
| 23 callbacks.shift()(); |
| 24 } |
| 25 } |
| 26 |
| 27 new (window.MutationObserver || JsMutationObserver)(atEndOfMicrotask) |
| 28 .observe(twiddle, {characterData: true}) |
| 29 ; |
| 30 |
| 31 // exports |
| 32 scope.endOfMicrotask = endOfMicrotask; |
| 33 // bc |
| 34 Platform.endOfMicrotask = endOfMicrotask; |
| 35 |
| 36 })(Polymer); |
| 37 |
OLD | NEW |