@dooboostore/dom-render
Version:
html view template engine
50 lines • 3.46 kB
JavaScript
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 DrStripElement extends OperatorExecuterAttrRequire {
constructor(rawSet, render, returnContainer, elementSource, source, afterCallBack) {
source.operatorAround = undefined;
super(rawSet, render, returnContainer, elementSource, source, afterCallBack, false);
}
executeAttrRequire(attr) {
return __awaiter(this, void 0, void 0, function* () {
var _a, _b, _c;
// const itRandom = RawSet.drItOtherEncoding(this.elementSource.element, 'DrStripElement');
// const vars = RawSet.drVarEncoding(this.elementSource.element, this.elementSource.attrs.drVarOption ?? '');
const newTemp = this.source.config.window.document.createElement('temp');
// Object.entries(this.__render.drAttr).filter(([k,v]) => k !== 'drIf' && v).forEach(([k, v]) => n.setAttribute(this.__render.drAttrsOriginName[k], v)); <-- 이부분은 다른 attr에도 적용을 할지말지 생각해야됨 엘리먼트 존재유무에 따라서 적용을 할지말지 결정해야됨
ScriptUtils.eval(`
${this.render.bindScript}
${(_a = this.elementSource.attrs.drBeforeOption) !== null && _a !== void 0 ? _a : ''}
const n = $element.cloneNode(true);
if(${attr}) {
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 : ''};
return true;
`, Object.assign(this.source.obj, {
__render: Object.freeze(Object.assign({ 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);
(_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=DrStripElement.js.map