@dooboostore/dom-render
Version:
html view template engine
37 lines (36 loc) • 1.72 kB
JavaScript
import { RawSet } from "../rawsets/RawSet.js";
import { ExecuteState, OperatorExecuter } from "./OperatorExecuter.js";
class DrTargetAttr extends 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 = 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 ExecuteState.EXECUTE;
}
return ExecuteState.NO_EXECUTE;
}
}
export {
DrTargetAttr
};
//# sourceMappingURL=DrTargetAttr.js.map