UNPKG

@dooboostore/dom-render

Version:
43 lines (42 loc) 2.02 kB
import { OperatorExecuterAttrRequire } from "./OperatorExecuterAttrRequire.js"; import { RawSet } from "../rawsets/RawSet.js"; import { ExecuteState } from "./OperatorExecuter.js"; import { ObjectUtils } from "@dooboostore/core"; class DrInnerHTML 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.innerHTML = ${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 // eslint-disable-next-line no-use-before-define }) })); 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 { DrInnerHTML }; //# sourceMappingURL=DrInnerHTML.js.map