@haxtheweb/haxcms-nodejs
Version:
HAXcms single and multisite nodejs server, api, and administration
10 lines • 4.37 kB
JavaScript
/**
@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{dedupingMixin as t}from"../utils/mixin.js";import{microTask as e}from"../utils/async.js";import{wrap as s}from"../utils/wrap.js";const i=e;export const PropertiesChanged=t((t=>class PropertiesChanged extends t{static createProperties(t){const e=this.prototype;for(let s in t)s in e||e._createPropertyAccessor(s)}static attributeNameForProperty(t){return t.toLowerCase()}static typeForProperty(t){}_createPropertyAccessor(t,e){this._addPropertyToAttributeMap(t),this.hasOwnProperty(JSCompiler_renameProperty("__dataHasAccessor",this))||(this.__dataHasAccessor=Object.assign({},this.__dataHasAccessor)),this.__dataHasAccessor[t]||(this.__dataHasAccessor[t]=!0,this._definePropertyAccessor(t,e))}_addPropertyToAttributeMap(t){this.hasOwnProperty(JSCompiler_renameProperty("__dataAttributes",this))||(this.__dataAttributes=Object.assign({},this.__dataAttributes));let e=this.__dataAttributes[t];return e||(e=this.constructor.attributeNameForProperty(t),this.__dataAttributes[e]=t),e}_definePropertyAccessor(t,e){Object.defineProperty(this,t,{get(){return this.__data[t]},set:e?function(){}:function(e){this._setPendingProperty(t,e,!0)&&this._invalidateProperties()}})}constructor(){super(),this.__dataEnabled=!1,this.__dataReady=!1,this.__dataInvalid=!1,this.__data={},this.__dataPending=null,this.__dataOld=null,this.__dataInstanceProps=null,this.__dataCounter=0,this.__serializing=!1,this._initializeProperties()}ready(){this.__dataReady=!0,this._flushProperties()}_initializeProperties(){for(let t in this.__dataHasAccessor)this.hasOwnProperty(t)&&(this.__dataInstanceProps=this.__dataInstanceProps||{},this.__dataInstanceProps[t]=this[t],delete this[t])}_initializeInstanceProperties(t){Object.assign(this,t)}_setProperty(t,e){this._setPendingProperty(t,e)&&this._invalidateProperties()}_getProperty(t){return this.__data[t]}_setPendingProperty(t,e,s){let i=this.__data[t],a=this._shouldPropertyChange(t,e,i);return a&&(this.__dataPending||(this.__dataPending={},this.__dataOld={}),this.__dataOld&&!(t in this.__dataOld)&&(this.__dataOld[t]=i),this.__data[t]=e,this.__dataPending[t]=e),a}_isPropertyPending(t){return!(!this.__dataPending||!this.__dataPending.hasOwnProperty(t))}_invalidateProperties(){!this.__dataInvalid&&this.__dataReady&&(this.__dataInvalid=!0,i.run((()=>{this.__dataInvalid&&(this.__dataInvalid=!1,this._flushProperties())})))}_enableProperties(){this.__dataEnabled||(this.__dataEnabled=!0,this.__dataInstanceProps&&(this._initializeInstanceProperties(this.__dataInstanceProps),this.__dataInstanceProps=null),this.ready())}_flushProperties(){this.__dataCounter++;const t=this.__data,e=this.__dataPending,s=this.__dataOld;this._shouldPropertiesChange(t,e,s)&&(this.__dataPending=null,this.__dataOld=null,this._propertiesChanged(t,e,s)),this.__dataCounter--}_shouldPropertiesChange(t,e,s){return Boolean(e)}_propertiesChanged(t,e,s){}_shouldPropertyChange(t,e,s){return s!==e&&(s==s||e==e)}attributeChangedCallback(t,e,s,i){e!==s&&this._attributeToProperty(t,s),super.attributeChangedCallback&&super.attributeChangedCallback(t,e,s,i)}_attributeToProperty(t,e,s){if(!this.__serializing){const i=this.__dataAttributes,a=i&&i[t]||t;this[a]=this._deserializeValue(e,s||this.constructor.typeForProperty(a))}}_propertyToAttribute(t,e,s){this.__serializing=!0,s=arguments.length<3?this[t]:s,this._valueToNodeAttribute(this,s,e||this.constructor.attributeNameForProperty(t)),this.__serializing=!1}_valueToNodeAttribute(t,e,i){const a=this._serializeValue(e);"class"!==i&&"name"!==i&&"slot"!==i||(t=s(t)),void 0===a?t.removeAttribute(i):t.setAttribute(i,""===a&&window.trustedTypes?window.trustedTypes.emptyScript:a)}_serializeValue(t){return"boolean"==typeof t?t?"":void 0:null!=t?t.toString():void 0}_deserializeValue(t,e){switch(e){case Boolean:return null!==t;case Number:return Number(t);default:return t}}}));