UNPKG

@haxtheweb/haxcms-nodejs

Version:

HAXcms single and multisite nodejs server, api, and administration

12 lines 7.31 kB
/** * @fileoverview * @suppress {checkPrototypalTypes} * @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 */ import"../utils/boot.js";import{rootPath as t,strictTemplatePolicy as e,allowTemplateFromDomModule as r,legacyOptimizations as o,legacyWarnings as s,syncInitialRender as i,supportsAdoptingStyleSheets as a,useAdoptedStyleSheetsWithBuiltCSS as n}from"../utils/settings.js";import{dedupingMixin as l}from"../utils/mixin.js";import{stylesFromTemplate as p,stylesFromModuleImports as h}from"../utils/style-gather.js";import{pathFromUrl as c,resolveCss as m,resolveUrl as y}from"../utils/resolve-url.js";import{DomModule as d}from"../elements/dom-module.js";import{PropertyEffects as f}from"./property-effects.js";import{PropertiesMixin as _}from"./properties-mixin.js";import{wrap as u}from"../utils/wrap.js";export const version="3.5.1";export const builtCSS=window.ShadyCSS&&window.ShadyCSS.cssBuild;export const ElementMixin=l((l=>{const S=_(f(l));return class PolymerElement extends S{static get polymerElementVersion(){return"3.5.1"}static _finalizeClass(){S._finalizeClass.call(this);const t=function ownObservers(t){return t.hasOwnProperty(JSCompiler_renameProperty("__ownObservers",t))||(t.__ownObservers=t.hasOwnProperty(JSCompiler_renameProperty("observers",t))?t.observers:null),t.__ownObservers}(this);t&&this.createObservers(t,this._properties),this._prepareTemplate()}static _prepareTemplate(){let t=this.template;t&&("string"==typeof t?(console.error("template getter must return HTMLTemplateElement"),t=null):o||(t=t.cloneNode(!0))),this.prototype._template=t}static createProperties(t){for(let i in t)e=this.prototype,r=i,o=t[i],s=t,o.computed&&(o.readOnly=!0),o.computed&&(e._hasReadOnlyEffect(r)?console.warn(`Cannot redefine computed property '${r}'.`):e._createComputedProperty(r,o.computed,s)),o.readOnly&&!e._hasReadOnlyEffect(r)?e._createReadOnlyProperty(r,!o.computed):!1===o.readOnly&&e._hasReadOnlyEffect(r)&&console.warn(`Cannot make readOnly property '${r}' non-readOnly.`),o.reflectToAttribute&&!e._hasReflectEffect(r)?e._createReflectedProperty(r):!1===o.reflectToAttribute&&e._hasReflectEffect(r)&&console.warn(`Cannot make reflected property '${r}' non-reflected.`),o.notify&&!e._hasNotifyEffect(r)?e._createNotifyingProperty(r):!1===o.notify&&e._hasNotifyEffect(r)&&console.warn(`Cannot make notify property '${r}' non-notify.`),o.observer&&e._createPropertyObserver(r,o.observer,s[o.observer]),e._addPropertyToAttributeMap(r);var e,r,o,s}static createObservers(t,e){const r=this.prototype;for(let o=0;o<t.length;o++)r._createMethodObserver(t[o],e)}static get template(){if(!this.hasOwnProperty(JSCompiler_renameProperty("_template",this))){let t=this.prototype.hasOwnProperty(JSCompiler_renameProperty("_template",this.prototype))?this.prototype._template:void 0;"function"==typeof t&&(t=t()),this._template=void 0!==t?t:this.hasOwnProperty(JSCompiler_renameProperty("is",this))&&function getTemplateFromDomModule(t){let o=null;if(t&&(!e||r)&&(o=d.import(t,"template"),e&&!o))throw new Error(`strictTemplatePolicy: expecting dom-module or null template for ${t}`);return o}(this.is)||Object.getPrototypeOf(this.prototype).constructor.template}return this._template}static set template(t){this._template=t}static get importPath(){if(!this.hasOwnProperty(JSCompiler_renameProperty("_importPath",this))){const t=this.importMeta;if(t)this._importPath=c(t.url);else{const t=d.import(this.is);this._importPath=t&&t.assetpath||Object.getPrototypeOf(this.prototype).constructor.importPath}}return this._importPath}constructor(){super(),this._template,this._importPath,this.rootPath,this.importPath,this.root,this.$}_initializeProperties(){this.constructor.finalize(),this.constructor._finalizeTemplate(this.localName),super._initializeProperties(),this.rootPath=t,this.importPath=this.constructor.importPath;let e=function propertyDefaults(t){if(!t.hasOwnProperty(JSCompiler_renameProperty("__propertyDefaults",t))){t.__propertyDefaults=null;let e=t._properties;for(let r in e){let o=e[r];"value"in o&&(t.__propertyDefaults=t.__propertyDefaults||{},t.__propertyDefaults[r]=o)}}return t.__propertyDefaults}(this.constructor);if(e)for(let t in e){let r=e[t];if(this._canApplyPropertyDefault(t)){let e="function"==typeof r.value?r.value.call(this):r.value;this._hasAccessor(t)?this._setPendingProperty(t,e,!0):this[t]=e}}}_canApplyPropertyDefault(t){return!this.hasOwnProperty(t)}static _processStyleText(t,e){return m(t,e)}static _finalizeTemplate(t){const e=this.prototype._template;if(e&&!e.__polymerFinalized){e.__polymerFinalized=!0;const r=this.importPath;!function processElementStyles(t,e,r,o){if(!builtCSS){const s=e.content.querySelectorAll("style"),i=p(e),a=h(r),n=e.content.firstElementChild;for(let r=0;r<a.length;r++){let s=a[r];s.textContent=t._processStyleText(s.textContent,o),e.content.insertBefore(s,n)}let l=0;for(let e=0;e<i.length;e++){let r=i[e],a=s[l];a!==r?(r=r.cloneNode(!0),a.parentNode.insertBefore(r,a)):l++,r.textContent=t._processStyleText(r.textContent,o)}}if(window.ShadyCSS&&window.ShadyCSS.prepareTemplate(e,r),n&&builtCSS&&a){const r=e.content.querySelectorAll("style");if(r){let e="";Array.from(r).forEach((t=>{e+=t.textContent,t.parentNode.removeChild(t)})),t._styleSheet=new CSSStyleSheet,t._styleSheet.replaceSync(e)}}}(this,e,t,r?y(r):""),this.prototype._bindTemplate(e)}}connectedCallback(){window.ShadyCSS&&this._template&&window.ShadyCSS.styleElement(this),super.connectedCallback()}ready(){this._template&&(this.root=this._stampTemplate(this._template),this.$=this.root.$),super.ready()}_readyClients(){this._template&&(this.root=this._attachDom(this.root)),super._readyClients()}_attachDom(t){const e=u(this);if(e.attachShadow)return t?(e.shadowRoot||(e.attachShadow({mode:"open",shadyUpgradeFragment:t}),e.shadowRoot.appendChild(t),this.constructor._styleSheet&&(e.shadowRoot.adoptedStyleSheets=[this.constructor._styleSheet])),i&&window.ShadyDOM&&window.ShadyDOM.flushInitial(e.shadowRoot),e.shadowRoot):null;throw new Error("ShadowDOM not available. PolymerElement can create dom as children instead of in ShadowDOM by setting `this.root = this;` before `ready`.")}updateStyles(t){window.ShadyCSS&&window.ShadyCSS.styleSubtree(this,t)}resolveUrl(t,e){return!e&&this.importPath&&(e=y(this.importPath)),y(t,e)}static _parseTemplateContent(t,e,r){return e.dynamicFns=e.dynamicFns||this._properties,S._parseTemplateContent.call(this,t,e,r)}static _addTemplatePropertyEffect(t,e,r){return!s||e in this._properties||r.info.part.signature&&r.info.part.signature.static||r.info.part.hostProp||t.nestedTemplate||console.warn(`Property '${e}' used in template but not declared in 'properties'; attribute will not be observed.`),S._addTemplatePropertyEffect.call(this,t,e,r)}}}));export const updateStyles=function(t){window.ShadyCSS&&window.ShadyCSS.styleDocument(t)};