| OLD | NEW |
| (Empty) | |
| 1 /** |
| 2 * @license |
| 3 * Copyright (c) 2014 The Polymer Project Authors. All rights reserved. |
| 4 * This code may only be used under the BSD style license found at http://polyme
r.github.io/LICENSE.txt |
| 5 * The complete set of authors may be found at http://polymer.github.io/AUTHORS.
txt |
| 6 * The complete set of contributors may be found at http://polymer.github.io/CON
TRIBUTORS.txt |
| 7 * Code distributed by Google as part of the polymer project is also |
| 8 * subject to an additional IP rights grant found at http://polymer.github.io/PA
TENTS.txt |
| 9 */ |
| 10 |
| 11 (function() { |
| 12 |
| 13 'use strict'; |
| 14 |
| 15 var customElements = window['customElements']; |
| 16 var HTMLImports = window['HTMLImports']; |
| 17 // global for (1) existence means `WebComponentsReady` will file, |
| 18 // (2) WebComponents.ready == true means event has fired. |
| 19 window.WebComponents = window.WebComponents || {}; |
| 20 |
| 21 if (customElements && customElements['polyfillWrapFlushCallback']) { |
| 22 // Here we ensure that the public `HTMLImports.whenReady` |
| 23 // always comes *after* custom elements have upgraded. |
| 24 var flushCallback; |
| 25 var runAndClearCallback = function runAndClearCallback() { |
| 26 if (flushCallback) { |
| 27 var cb = flushCallback; |
| 28 flushCallback = null; |
| 29 cb(); |
| 30 return true; |
| 31 } |
| 32 } |
| 33 var origWhenReady = HTMLImports['whenReady']; |
| 34 customElements['polyfillWrapFlushCallback'](function(cb) { |
| 35 flushCallback = cb; |
| 36 origWhenReady(runAndClearCallback); |
| 37 }); |
| 38 |
| 39 HTMLImports['whenReady'] = function(cb) { |
| 40 origWhenReady(function() { |
| 41 // custom element code may add dynamic imports |
| 42 // to match processing of native custom elements before |
| 43 // domContentLoaded, we wait for these imports to resolve first. |
| 44 if (runAndClearCallback()) { |
| 45 HTMLImports['whenReady'](cb); |
| 46 } else { |
| 47 cb(); |
| 48 } |
| 49 }); |
| 50 } |
| 51 |
| 52 } |
| 53 |
| 54 HTMLImports['whenReady'](function() { |
| 55 requestAnimationFrame(function() { |
| 56 window.WebComponents.ready = true; |
| 57 document.dispatchEvent(new CustomEvent('WebComponentsReady', {bubbles: tru
e})); |
| 58 }); |
| 59 }); |
| 60 |
| 61 })(); |
| OLD | NEW |