@dooboostore/dom-render
Version:
html view template engine
56 lines (55 loc) • 2.71 kB
JavaScript
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 DrTargetAttr_exports = {};
__export(DrTargetAttr_exports, {
DrTargetAttr: () => DrTargetAttr
});
module.exports = __toCommonJS(DrTargetAttr_exports);
var import_RawSet = require("../rawsets/RawSet");
var import_OperatorExecuter = require("./OperatorExecuter");
class DrTargetAttr extends import_OperatorExecuter.OperatorExecuter {
constructor(rawSet, render, returnContainer, elementSource, source, afterCallBack) {
source.operatorAround = void 0;
super(rawSet, render, returnContainer, elementSource, source, afterCallBack, false);
}
async execute() {
const attributeNames = this.elementSource.element.getAttributeNames();
const targetAttr = this.source.config?.targetAttrs?.find((it) => attributeNames.includes(it.name));
if (targetAttr) {
const attrName = targetAttr.name;
const attrValue = this.rawSet.getAttributeAndDelete(this.elementSource.element, attrName);
if (attrValue && attrName && (!this.elementSource.attrs.drForOf && !this.elementSource.attrs.drFor && !this.elementSource.attrs.drRepeat)) {
const documentFragment = targetAttr.callBack(this.elementSource.element, attrValue, this.source.obj, this.rawSet);
if (documentFragment) {
const rr = import_RawSet.RawSet.checkPointCreates(documentFragment, this.source.obj, this.source.config);
this.elementSource.element.parentNode?.replaceChild(documentFragment, this.elementSource.element);
this.returnContainer.raws.push(...rr);
this.afterCallBack.onAttrInitCallBacks.push({
attrName,
attrValue,
obj: this.source.obj
});
targetAttr?.complete?.(this.elementSource.element, attrValue, this.source.obj, this.rawSet);
}
}
return import_OperatorExecuter.ExecuteState.EXECUTE;
}
return import_OperatorExecuter.ExecuteState.NO_EXECUTE;
}
}
//# sourceMappingURL=DrTargetAttr.js.map