/** * @license * Copyright (c) 2018 The Polymer Project Authors. All rights reserved. * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt * Code distributed by Google as part of the polymer project is also * subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */ (function() { 'use strict'; /** * Basic flow of the loader process * * There are 4 flows the loader can take when booting up * * - Synchronous script, no polyfills needed * - wait for `DOMContentLoaded` * - run callbacks passed to `waitFor` * - fire WCR event * * - Synchronous script, polyfills needed * - document.write the polyfill bundle * - wait on the `load` event of the bundle to batch Custom Element upgrades * - wait for `DOMContentLoaded` * - run callbacks passed to `waitFor` * - fire WCR event * * - Asynchronous script, no polyfills needed * - fire WCR event, as there could not be any callbacks passed to `waitFor` * * - Asynchronous script, polyfills needed * - Append the polyfill bundle script * - wait for `load` event of the bundle * - batch Custom Element Upgrades * - run callbacks pass to `waitFor` * - fire WCR event */ var polyfillsLoaded = false; var whenLoadedFns = []; var allowUpgrades = false; var flushFn; function fireEvent() { window.WebComponents.ready = true; document.dispatchEvent(new CustomEvent('WebComponentsReady', { bubbles: true })); } function batchCustomElements() { if (window.customElements && customElements.polyfillWrapFlushCallback) { customElements.polyfillWrapFlushCallback(function (flushCallback) { flushFn = flushCallback; if (allowUpgrades) { flushFn(); } }); } } function asyncReady() { batchCustomElements(); ready(); } function ready() { // bootstrap