UNPKG

@dooboostore/dom-render

Version:
46 lines 2.92 kB
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; import { OperatorExecuterAttrRequire } from './OperatorExecuterAttrRequire'; import { ScriptUtils } from '@dooboostore/core-web/script/ScriptUtils'; import { RawSet } from '../rawsets/RawSet'; import { ExecuteState } from './OperatorExecuter'; export class DrInnerText extends OperatorExecuterAttrRequire { constructor(rawSet, render, returnContainer, elementSource, source, afterCallBack) { super(rawSet, render, returnContainer, elementSource, source, afterCallBack, false); } executeAttrRequire(attr) { return __awaiter(this, void 0, void 0, function* () { var _a, _b, _c; const newTemp = this.source.config.window.document.createElement('temp'); ScriptUtils.eval(` ${this.render.bindScript} const n = $element.cloneNode(true); ${(_a = this.elementSource.attrs.drBeforeOption) !== null && _a !== void 0 ? _a : ''} 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); } ${(_b = this.elementSource.attrs.drAfterOption) !== null && _b !== void 0 ? _b : ''} `, Object.assign(this.source.obj, { __render: Object.freeze(Object.assign({ 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); (_c = this.elementSource.element.parentNode) === null || _c === void 0 ? void 0 : _c.replaceChild(this.returnContainer.fag, this.elementSource.element); this.returnContainer.raws.push(...rr); return ExecuteState.EXECUTE; }); } } //# sourceMappingURL=DrInnerText.js.map