@popeindustries/lit-html
Version:
Seamlessly and efficiently use @popeindustries/lit-html-server rendered HTML to hydrate lit-html templates in the browser
6 lines (5 loc) • 1.89 kB
JavaScript
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/import{isSingleExpression as a}from"./directive-helpers.js";import{Directive as c,PartType as h}from"./directive.js";export*from"./directive.js";const l=(i,e)=>{var n,t;const s=i._$disconnectableChildren;if(s===void 0)return!1;for(const r of s)(t=(n=r)._$notifyDirectiveConnectionChanged)===null||t===void 0||t.call(n,e,!1),l(r,e);return!0},d=i=>{let e,n;do{if((e=i._$parent)===void 0)break;n=e._$disconnectableChildren,n.delete(i),i=e}while(n?.size===0)},o=i=>{for(let e;e=i._$parent;i=e){let n=e._$disconnectableChildren;if(n===void 0)e._$disconnectableChildren=n=new Set;else if(n.has(i))break;n.add(i),u(e)}};function _(i){this._$disconnectableChildren!==void 0?(d(this),this._$parent=i,o(this)):this._$parent=i}function f(i,e=!1,n=0){const t=this._$committedValue,s=this._$disconnectableChildren;if(!(s===void 0||s.size===0))if(e)if(Array.isArray(t))for(let r=n;r<t.length;r++)l(t[r],!1),d(t[r]);else t!=null&&(l(t,!1),d(t));else l(this,i)}const u=i=>{var e,n,t,s;i.type==h.CHILD&&((e=(t=i)._$notifyConnectionChanged)!==null&&e!==void 0||(t._$notifyConnectionChanged=f),(n=(s=i)._$reparentDisconnectables)!==null&&n!==void 0||(s._$reparentDisconnectables=_))};class C extends c{constructor(){super(...arguments),this._$disconnectableChildren=void 0}_$initialize(e,n,t){super._$initialize(e,n,t),o(this),this.isConnected=e._$isConnected}_$notifyDirectiveConnectionChanged(e,n=!0){var t,s;e!==this.isConnected&&(this.isConnected=e,e?(t=this.reconnected)===null||t===void 0||t.call(this):(s=this.disconnected)===null||s===void 0||s.call(this)),n&&(l(this,e),d(this))}setValue(e){if(a(this.__part))this.__part._$setValue(e,this);else{const n=[...this.__part._$committedValue];n[this.__attributeIndex]=e,this.__part._$setValue(n,this,0)}}disconnected(){}reconnected(){}}export{C as AsyncDirective};