UNPKG

@dooboostore/dom-render

Version:
72 lines 5.3 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 { RawSet } from '../rawsets/RawSet'; import { ComponentSet } from '../components/ComponentSet'; import { ExecuteState } from './OperatorExecuter'; import { isOnDrThisUnBind } from '../lifecycle/dr-this/OnDrThisUnBind'; import { isOnDrThisBind } from '../lifecycle/dr-this/OnDrThisBind'; export class DrThis extends OperatorExecuterAttrRequire { executeAttrRequire(attr) { return __awaiter(this, void 0, void 0, function* () { var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o; // console.log('drThis!!!!!!!!!!!!!',this.elementSource.attrs.drThis); if (attr && this.elementSource.attrs.drThis) { let thisPath = this.elementSource.attrs.drThis; if (attr instanceof ComponentSet) { // console.log('drThis!!!!!!!!!!->', attr) // if (this.rawSet.data) { // const destroyOptions = this.elementSource.attrs.drDestroyOption?.split(',') ?? []; // debugger; // RawSet.destroy((this.rawSet.data as ComponentSet).obj, [], this.source.config, destroyOptions); // } if (((_b = (_a = attr.config) === null || _a === void 0 ? void 0 : _a.beforeComponentSet) === null || _b === void 0 ? void 0 : _b.obj) !== attr.obj) { if (isOnDrThisUnBind((_c = attr.config.beforeComponentSet) === null || _c === void 0 ? void 0 : _c.obj)) { (_f = (_e = (_d = attr.config.beforeComponentSet) === null || _d === void 0 ? void 0 : _d.obj) === null || _e === void 0 ? void 0 : _e.onDrThisUnBind) === null || _f === void 0 ? void 0 : _f.call(_e); } } // this.rawSet.dataSet ??= {}; // this.rawSet.dataSet.data = attr; if (((_h = (_g = attr.config) === null || _g === void 0 ? void 0 : _g.beforeComponentSet) === null || _h === void 0 ? void 0 : _h.obj) !== attr.obj) { if (isOnDrThisBind(attr.obj)) { (_k = (_j = attr.obj) === null || _j === void 0 ? void 0 : _j.onDrThisBind) === null || _k === void 0 ? void 0 : _k.call(_j); } } // 중요: componentSet 의 objPath를 보고 판단하는 중요한부분 thisPath = `${this.elementSource.attrs.drThis}${attr.config.objPath ? ('.' + attr.config.objPath) : ''}`; this.setThisPath(thisPath); const componentBody = yield RawSet.drThisCreate(this.rawSet, this.elementSource.element, thisPath, (_l = this.elementSource.attrs.drVarOption) !== null && _l !== void 0 ? _l : '', this.elementSource.attrs.drStripOption, this.source.obj, this.source.config, attr); this.returnContainer.fag.append(componentBody); this.afterCallBack.onThisComponentSetCallBacks.push(attr); } else { this.setThisPath(thisPath); this.returnContainer.fag.append(yield RawSet.drThisCreate(this.rawSet, this.elementSource.element, this.elementSource.attrs.drThis, (_m = this.elementSource.attrs.drVarOption) !== null && _m !== void 0 ? _m : '', this.elementSource.attrs.drStripOption, this.source.obj, this.source.config)); } // console.log('!!!!!!!!!zzz', Array.from(this.returnContainer.fag.childNodes), this.elementSource.element); const rr = RawSet.checkPointCreates(this.returnContainer.fag, this.source.obj, this.source.config); (_o = this.elementSource.element.parentNode) === null || _o === void 0 ? void 0 : _o.replaceChild(this.returnContainer.fag, this.elementSource.element); this.returnContainer.raws.push(...rr); } else { this.elementSource.element.remove(); } return ExecuteState.EXECUTE; }); } setThisPath(thisPath) { // if (this.rawSet.point.start instanceof HTMLMetaElement && this.rawSet.point.end instanceof HTMLMetaElement) { if (this.rawSet.point.start instanceof this.source.config.window.HTMLMetaElement && this.rawSet.point.end instanceof this.source.config.window.HTMLMetaElement) { this.rawSet.point.start.setAttribute('this-path', thisPath); this.rawSet.point.end.setAttribute('this-path', thisPath); } } } //# sourceMappingURL=DrThis.js.map