UNPKG

@dooboostore/dom-render

Version:
101 lines (100 loc) 5.4 kB
var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); var DrThisProperty_exports = {}; __export(DrThisProperty_exports, { DrThisProperty: () => DrThisProperty }); module.exports = __toCommonJS(DrThisProperty_exports); var import_OperatorExecuterAttrRequire = require("./OperatorExecuterAttrRequire"); var import_core_web = require("@dooboostore/core-web"); var import_RawSet = require("../rawsets/RawSet"); var import_OperatorExecuter = require("./OperatorExecuter"); var import_core = require("@dooboostore/core"); class DrThisProperty extends import_OperatorExecuterAttrRequire.OperatorExecuterAttrRequire { constructor(rawSet, render, returnContainer, elementSource, source, afterCallBack) { source.operatorAround = void 0; super(rawSet, render, returnContainer, elementSource, source, afterCallBack, false); } async executeAttrRequire(attr) { const itRandom = import_RawSet.RawSet.drItOtherEncoding(this.elementSource.element, "DrThisProperty"); const vars = import_RawSet.RawSet.drVarEncoding(this.elementSource.element, this.elementSource.attrs.drVarOption ?? ""); const newTemp = this.source.config.window.document.createElement("temp"); const dictioanry = import_core_web.ScriptUtils.evaluateReturn(attr, this.source.obj); const dictionaryKey = this.elementSource.attrs.drKeyOption ?? ""; import_core.ObjectUtils.Script.evaluate(` ${this.render.bindScript} ${this.elementSource.attrs.drBeforeOption ?? ""} var i = 0; const dictionary = ${attr}; const dictionaryKey = '${dictionaryKey}'; const dictionaryStr = \`${attr}\`.trim(); // console.log('----@#!@#@!#', this.__render.oldChild); if (dictionary) { for(const it in dictionary) { var destIt = dictionaryStr + '["' + it + '"]'; const n = this.__render.element.cloneNode(true); n.setAttribute('dr-this', destIt); n.setAttribute('${import_RawSet.RawSet.DR_KEY_OPTIONNAME}', it); // n.setAttribute('dr-dictionary-key', it); this.__render.fag.append(n); i++; } this.__render.rawset.point.start.setAttribute('${import_RawSet.RawSet.DR_HAS_KEYS_OPTIONNAME}',Object.keys(dictionary).join(',')); } ${this.elementSource.attrs.drAfterOption ?? ""} `, Object.assign(this.source.obj, { __render: Object.freeze({ drStripOption: this.elementSource.attrs.drStripOption, drAttr: this.elementSource.attrs, drAttrsOriginName: import_RawSet.RawSet.drAttrsOriginName, fag: newTemp, ...this.render }) })); import_RawSet.RawSet.drVarDecoding(newTemp, vars); import_RawSet.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 = import_RawSet.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 import_OperatorExecuter.ExecuteState.EXECUTE; } static append(obj, fullPath, key, rawSet, config) { const genNode = config.window.document.importNode(rawSet.dataSet.fragment, true); const rawSets = []; for (const cNode of Array.from(genNode.childNodes.values())) { const element = cNode.cloneNode(true); element.removeAttribute(import_RawSet.RawSet.DR_THIS_PROPERTY_NAME); element.setAttribute(import_RawSet.RawSet.DR_THIS_NAME, `this.${fullPath}`); element.setAttribute(import_RawSet.RawSet.DR_KEY_OPTIONNAME, key); const fg = config.window.document.createDocumentFragment(); fg.append(element); rawSets.push(...import_RawSet.RawSet.checkPointCreates(fg, obj, config)); rawSet.point.end.before(fg); const start = rawSet.point.start; const keys = start.getAttribute(import_RawSet.RawSet.DR_HAS_KEYS_OPTIONNAME)?.split(",") ?? []; keys.push(key); start.setAttribute(import_RawSet.RawSet.DR_HAS_KEYS_OPTIONNAME, keys.join(",")); rawSets.forEach(async (it) => await it.render(obj, config)); } return rawSets; } } //# sourceMappingURL=DrThisProperty.js.map