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

Unified Diff: appengine/config_service/ui/bower_components/polymer/lib/elements/dom-bind.html

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/polymer/lib/elements/dom-bind.html
diff --git a/appengine/config_service/ui/bower_components/polymer/lib/elements/dom-bind.html b/appengine/config_service/ui/bower_components/polymer/lib/elements/dom-bind.html
new file mode 100644
index 0000000000000000000000000000000000000000..19497e0d32f01a71acc69c954f32e4233c220f4d
--- /dev/null
+++ b/appengine/config_service/ui/bower_components/polymer/lib/elements/dom-bind.html
@@ -0,0 +1,121 @@
+<!--
+@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
+-->
+
+<link rel="import" href="../utils/boot.html">
+<link rel="import" href="../mixins/property-effects.html">
+<link rel="import" href="../mixins/mutable-data.html">
+<link rel="import" href="../mixins/gesture-event-listeners.html">
+
+<script>
+
+ (function() {
+ 'use strict';
+
+ /**
+ * @constructor
+ * @implements {Polymer_PropertyEffects}
+ * @implements {Polymer_OptionalMutableData}
+ * @implements {Polymer_GestureEventListener}
+ * @extends {HTMLElement}
+ */
+ const domBindBase =
+ Polymer.GestureEventListeners(
+ Polymer.OptionalMutableData(
+ Polymer.PropertyEffects(HTMLElement)));
+
+ /**
+ * Custom element to allow using Polymer's template features (data binding,
+ * declarative event listeners, etc.) in the main document without defining
+ * a new custom element.
+ *
+ * `<template>` tags utilizing bindings may be wrapped with the `<dom-bind>`
+ * element, which will immediately stamp the wrapped template into the main
+ * document and bind elements to the `dom-bind` element itself as the
+ * binding scope.
+ *
+ * @extends HTMLElement
+ * @mixes Polymer.PropertyEffects
+ * @memberof Polymer
+ * @summary Custom element to allow using Polymer's template features (data
+ * binding, declarative event listeners, etc.) in the main document.
+ */
+ class DomBind extends domBindBase {
+
+ static get observedAttributes() { return ['mutable-data'] }
+
+ // assumes only one observed attribute
+ attributeChangedCallback() {
+ this.mutableData = true;
+ }
+
+ connectedCallback() {
+ this.render();
+ }
+
+ disconnectedCallback() {
+ this.__removeChildren();
+ }
+
+ __insertChildren() {
+ this.parentNode.insertBefore(this.root, this);
+ }
+
+ __removeChildren() {
+ if (this.__children) {
+ for (let i=0; i<this.__children.length; i++) {
+ this.root.appendChild(this.__children[i]);
+ }
+ }
+ }
+
+ /**
+ * Forces the element to render its content. This is typically only
+ * necessary to call if HTMLImports with the async attribute are used.
+ */
+ render() {
+ let template;
+ if (!this.__children) {
+ template = template || this.querySelector('template');
+ if (!template) {
+ // Wait until childList changes and template should be there by then
+ let observer = new MutationObserver(() => {
+ template = this.querySelector('template');
+ if (template) {
+ observer.disconnect();
+ this.render(template);
+ } else {
+ throw new Error('dom-bind requires a <template> child');
+ }
+ })
+ observer.observe(this, {childList: true});
+ return;
+ }
+ this.root = this._stampTemplate(template);
+ this.$ = this.root.$;
+ this.__children = [];
+ for (let n=this.root.firstChild; n; n=n.nextSibling) {
+ this.__children[this.__children.length] = n;
+ }
+ this._enableProperties();
+ }
+ this.__insertChildren();
+ this.dispatchEvent(new CustomEvent('dom-change', {
+ bubbles: true,
+ composed: true
+ }));
+ }
+
+ }
+
+ customElements.define('dom-bind', DomBind);
+
+ })();
+
+</script>

Powered by Google App Engine
This is Rietveld 408576698