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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: appengine/config_service/ui/bower_components/webcomponentsjs/webcomponents-loader.js
diff --git a/appengine/config_service/ui/bower_components/webcomponentsjs/webcomponents-loader.js b/appengine/config_service/ui/bower_components/webcomponentsjs/webcomponents-loader.js
new file mode 100644
index 0000000000000000000000000000000000000000..ff0c6fd2c8cff08d730b72dd15297ebe1173c609
--- /dev/null
+++ b/appengine/config_service/ui/bower_components/webcomponentsjs/webcomponents-loader.js
@@ -0,0 +1,74 @@
+/**
+ * @license
+ * Copyright (c) 2017 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';
+ // global for (1) existence means `WebComponentsReady` will file,
+ // (2) WebComponents.ready == true means event has fired.
+ window.WebComponents = window.WebComponents || {};
+ var name = 'webcomponents-loader.js';
+ // Feature detect which polyfill needs to be imported.
+ var polyfills = [];
+ if (!('import' in document.createElement('link'))) {
+ polyfills.push('hi');
+ }
+ if (!('attachShadow' in Element.prototype && 'getRootNode' in Element.prototype) ||
+ (window.ShadyDOM && window.ShadyDOM.force)) {
+ polyfills.push('sd');
+ }
+ if (!window.customElements || window.customElements.forcePolyfill) {
+ polyfills.push('ce');
+ }
+ // NOTE: any browser that does not have template or ES6 features
+ // must load the full suite (called `lite` for legacy reasons) of polyfills.
+ if (!('content' in document.createElement('template')) || !window.Promise || !Array.from ||
+ // Edge has broken fragment cloning which means you cannot clone template.content
+ !(document.createDocumentFragment().cloneNode() instanceof DocumentFragment)) {
+ polyfills = ['lite'];
+ }
+
+ if (polyfills.length) {
+ var script = document.querySelector('script[src*="' + name +'"]');
+ var newScript = document.createElement('script');
+ // Load it from the right place.
+ var replacement = 'webcomponents-' + polyfills.join('-') + '.js';
+ var url = script.src.replace(name, replacement);
+ newScript.src = url;
+ // NOTE: this is required to ensure the polyfills are loaded before
+ // *native* html imports load on older Chrome versions. This *is* CSP
+ // compliant since CSP rules must have allowed this script to run.
+ // In all other cases, this can be async.
+ if (document.readyState === 'loading' && ('import' in document.createElement('link'))) {
+ document.write(newScript.outerHTML);
+ } else {
+ document.head.appendChild(newScript);
+ }
+ } else {
+ // Ensure `WebComponentsReady` is fired also when there are no polyfills loaded.
+ // however, we have to wait for the document to be in 'interactive' state,
+ // otherwise a rAF may fire before scripts in <body>
+
+ var fire = function() {
+ requestAnimationFrame(function() {
+ window.WebComponents.ready = true;
+ document.dispatchEvent(new CustomEvent('WebComponentsReady', {bubbles: true}));
+ });
+ };
+
+ if (document.readyState !== 'loading') {
+ fire();
+ } else {
+ document.addEventListener('readystatechange', function wait() {
+ fire();
+ document.removeEventListener('readystatechange', wait);
+ });
+ }
+ }
+})();

Powered by Google App Engine
This is Rietveld 408576698