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 // inject style sheet |
| 13 var style = document.createElement('style'); |
| 14 style.textContent = 'template {display: none !important;} /* injected by platfor
m.js */'; |
| 15 var head = document.querySelector('head'); |
| 16 head.insertBefore(style, head.firstChild); |
| 17 |
| 18 // flush (with logging) |
| 19 var flushing; |
| 20 function flush() { |
| 21 if (!flushing) { |
| 22 flushing = true; |
| 23 scope.endOfMicrotask(function() { |
| 24 flushing = false; |
| 25 logFlags.data && console.group('Platform.flush()'); |
| 26 scope.performMicrotaskCheckpoint(); |
| 27 logFlags.data && console.groupEnd(); |
| 28 }); |
| 29 } |
| 30 }; |
| 31 |
| 32 // polling dirty checker |
| 33 // flush periodically if platform does not have object observe. |
| 34 if (!Observer.hasObjectObserve) { |
| 35 var FLUSH_POLL_INTERVAL = 125; |
| 36 window.addEventListener('WebComponentsReady', function() { |
| 37 flush(); |
| 38 scope.flushPoll = setInterval(flush, FLUSH_POLL_INTERVAL); |
| 39 }); |
| 40 } else { |
| 41 // make flush a no-op when we have Object.observe |
| 42 flush = function() {}; |
| 43 } |
| 44 |
| 45 if (window.CustomElements && !CustomElements.useNative) { |
| 46 var originalImportNode = Document.prototype.importNode; |
| 47 Document.prototype.importNode = function(node, deep) { |
| 48 var imported = originalImportNode.call(this, node, deep); |
| 49 CustomElements.upgradeAll(imported); |
| 50 return imported; |
| 51 } |
| 52 } |
| 53 |
| 54 // exports |
| 55 scope.flush = flush; |
| 56 |
| 57 })(window.Platform); |
| 58 |
OLD | NEW |