UNPKG

@dooboostore/dom-render

Version:
42 lines (41 loc) 1.96 kB
import { OperatorExecuterAttrRequire } from "./OperatorExecuterAttrRequire.js"; import { RawSet } from "../rawsets/RawSet.js"; import { ExecuteState } from "./OperatorExecuter.js"; import { ObjectUtils } from "@dooboostore/core"; class DrInnerText extends OperatorExecuterAttrRequire { constructor(rawSet, render, returnContainer, elementSource, source, afterCallBack) { 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} const n = $element.cloneNode(true); ${this.elementSource.attrs.drBeforeOption ?? ""} n.innerText = ${attr}; if (this.__render.drStripOption === 'true') { Array.from(n.childNodes).forEach(it => this.__render.fag.append(it)); } else { this.__render.fag.append(n); } ${this.elementSource.attrs.drAfterOption ?? ""} `, Object.assign(this.source.obj, { __render: Object.freeze({ drStripOption: this.elementSource.attrs.drStripOption, fag: newTemp, ...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 { DrInnerText }; //# sourceMappingURL=DrInnerText.js.map