Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(471)

Side by Side Diff: appengine/config_service/ui/bower_components/webcomponentsjs/webcomponents-loader.js

Issue 2923973003: Added base template for config ui. (Closed)
Patch Set: Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 /**
2 * @license
3 * Copyright (c) 2017 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 'use strict';
13 // global for (1) existence means `WebComponentsReady` will file,
14 // (2) WebComponents.ready == true means event has fired.
15 window.WebComponents = window.WebComponents || {};
16 var name = 'webcomponents-loader.js';
17 // Feature detect which polyfill needs to be imported.
18 var polyfills = [];
19 if (!('import' in document.createElement('link'))) {
20 polyfills.push('hi');
21 }
22 if (!('attachShadow' in Element.prototype && 'getRootNode' in Element.prototyp e) ||
23 (window.ShadyDOM && window.ShadyDOM.force)) {
24 polyfills.push('sd');
25 }
26 if (!window.customElements || window.customElements.forcePolyfill) {
27 polyfills.push('ce');
28 }
29 // NOTE: any browser that does not have template or ES6 features
30 // must load the full suite (called `lite` for legacy reasons) of polyfills.
31 if (!('content' in document.createElement('template')) || !window.Promise || ! Array.from ||
32 // Edge has broken fragment cloning which means you cannot clone template.co ntent
33 !(document.createDocumentFragment().cloneNode() instanceof DocumentFragment) ) {
34 polyfills = ['lite'];
35 }
36
37 if (polyfills.length) {
38 var script = document.querySelector('script[src*="' + name +'"]');
39 var newScript = document.createElement('script');
40 // Load it from the right place.
41 var replacement = 'webcomponents-' + polyfills.join('-') + '.js';
42 var url = script.src.replace(name, replacement);
43 newScript.src = url;
44 // NOTE: this is required to ensure the polyfills are loaded before
45 // *native* html imports load on older Chrome versions. This *is* CSP
46 // compliant since CSP rules must have allowed this script to run.
47 // In all other cases, this can be async.
48 if (document.readyState === 'loading' && ('import' in document.createElement ('link'))) {
49 document.write(newScript.outerHTML);
50 } else {
51 document.head.appendChild(newScript);
52 }
53 } else {
54 // Ensure `WebComponentsReady` is fired also when there are no polyfills loa ded.
55 // however, we have to wait for the document to be in 'interactive' state,
56 // otherwise a rAF may fire before scripts in <body>
57
58 var fire = function() {
59 requestAnimationFrame(function() {
60 window.WebComponents.ready = true;
61 document.dispatchEvent(new CustomEvent('WebComponentsReady', {bubbles: t rue}));
62 });
63 };
64
65 if (document.readyState !== 'loading') {
66 fire();
67 } else {
68 document.addEventListener('readystatechange', function wait() {
69 fire();
70 document.removeEventListener('readystatechange', wait);
71 });
72 }
73 }
74 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698