1/** 2@license 3Copyright (c) 2016 The Polymer Project Authors. All rights reserved. 4This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt 5The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt 6The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt 7Code distributed by Google as part of the polymer project is also 8subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt 9*/ 10 11/* 12A simple webcomponents helper 13*/ 14'use strict'; 15 16window.makeElement = (name, connectedCallback) => { 17 let template = document.querySelector(`template#${name}`); 18 if (template && window.ShadyCSS) { 19 window.ShadyCSS.prepareTemplate(template, name); 20 } 21 window.customElements.define(name, class extends window.HTMLElement { 22 connectedCallback() { 23 window.ShadyCSS && window.ShadyCSS.styleElement(this); 24 if (!this.shadowRoot) { 25 this.attachShadow({mode: 'open'}); 26 if (template) { 27 this.shadowRoot.appendChild(template.content.cloneNode(true)); 28 } 29 } 30 if (connectedCallback) { 31 connectedCallback.call(this); 32 } 33 } 34 }); 35}; 36