UNPKG

@dooboostore/dom-render

Version:
53 lines 3.39 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 Dr extends OperatorExecuterAttrRequire { constructor(rawSet, render, returnContainer, elementSource, source, afterCallBack) { super(rawSet, render, returnContainer, elementSource, source, afterCallBack); } executeAttrRequire(data) { return __awaiter(this, void 0, void 0, function* () { var _a, _b; const itRandom = RawSet.drItOtherEncoding(this.elementSource.element); const vars = RawSet.drVarEncoding(this.elementSource.element, (_a = this.elementSource.attrs.drVarOption) !== null && _a !== void 0 ? _a : ''); const newTemp = this.source.config.window.document.createElement('temp'); ScriptUtils.eval(` ${this.render.bindScript} const n = $element.cloneNode(true); var destIt = ${this.elementSource.attrs.drItOption}; if (destIt !== undefined) { n.getAttributeNames().forEach(it => n.setAttribute(it, n.getAttribute(it).replace(/\\#it\\#/g, destIt))) // console.log('----', n.innerHTML); n.innerHTML = n.innerHTML.replace(/\\#it\\#/g, destIt); // console.log('----', n.innerHTML); } if (this.__render.drStripOption === 'true') { Array.from(n.childNodes).forEach(it => this.__fag.append(it)); } else { this.__render.fag.append(n); }`, Object.assign(this.source.obj, { __render: Object.freeze(Object.assign({ fag: newTemp, drStripOption: this.elementSource.attrs.drStripOption }, this.render)) })); RawSet.drVarDecoding(newTemp, vars); RawSet.drItOtherDecoding(newTemp, itRandom); 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); (_b = this.elementSource.element.parentNode) === null || _b === void 0 ? void 0 : _b.replaceChild(this.returnContainer.fag, this.elementSource.element); this.returnContainer.raws.push(...rr); return ExecuteState.EXECUTE; }); } } //# sourceMappingURL=Dr.js.map