UNPKG

@dooboostore/dom-render

Version:
48 lines (47 loc) 2 kB
import { OperatorExecuterAttrRequire } from "./OperatorExecuterAttrRequire.js"; import { RawSet } from "../rawsets/RawSet.js"; import { ExecuteState } from "./OperatorExecuter.js"; import { ObjectUtils } from "@dooboostore/core"; class DrStripElement extends OperatorExecuterAttrRequire { constructor(rawSet, render, returnContainer, elementSource, source, afterCallBack) { source.operatorAround = void 0; super(rawSet, render, returnContainer, elementSource, source, afterCallBack, false); } async executeAttrRequire(attr) { const newTemp = this.source.config.window.document.createElement("temp"); ObjectUtils.Script.evaluate(` ${this.render.bindScript} ${this.elementSource.attrs.drBeforeOption ?? ""} const n = $element.cloneNode(true); if(${attr}) { Array.from(n.childNodes).forEach(it => this.__render.fag.append(it)); } else { this.__render.fag.append(n); } ${this.elementSource.attrs.drAfterOption ?? ""}; return true; `, Object.assign( this.source.obj, { __render: Object.freeze({ fag: newTemp, drAttr: this.elementSource.attrs, drAttrsOriginName: RawSet.drAttrsOriginName, drStripOption: this.elementSource.attrs.drStripOption, ...this.render }) } )); const tempalte = this.source.config.window.document.createElement("template"); tempalte.innerHTML = newTemp.innerHTML; this.returnContainer.fag.append(tempalte.content); const rr = RawSet.checkPointCreates(this.returnContainer.fag, this.source.obj, this.source.config); this.elementSource.element.parentNode?.replaceChild(this.returnContainer.fag, this.elementSource.element); this.returnContainer.raws.push(...rr); return ExecuteState.EXECUTE; } } export { DrStripElement }; //# sourceMappingURL=DrStripElement.js.map