Skip to content

Commit

Permalink
version 3.2.0-alpha.43
Browse files Browse the repository at this point in the history
  • Loading branch information
antonmak1 committed Apr 9, 2024
1 parent 0e37796 commit 4b59c23
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cample",
"version": "3.2.0-alpha.42",
"version": "3.2.0-alpha.43",
"description": "Cample.js - fast modern javascript framework. Reactivity without virtual DOM!",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
83 changes: 81 additions & 2 deletions src/core/functions/render/render-el.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ import {
EventEachGetDataType,
EventEachGetFunctionType,
EventGetDataType,
ImportDataType,
IndexObjNode,
ValueItemType,
ValueItemsType,
ValueType,
ValueValueType,
Expand Down Expand Up @@ -341,8 +343,85 @@ export const renderEl = (
};
const keyArr = [...e.value.matchAll(TEXT_REGEX)];
if (keyArr.length === 1) {
keyTemplate.value = createValItem(getVal(keyArr[0]));
keyTemplate.render = valueFunctions[1];
const val = getVal(keyArr[0]);
keyTemplate.value = createValItem(val);
if (typeof val === "string") {
keyTemplate.render = valueFunctions[1];
} else {
const { render: renderVal } = val;
if (val.properties?.length === 1 && !val.isValue) {
const prop = (val.properties as any)[0];
switch (val.originType) {
case 1:
keyTemplate.render = (
indexData: any,
value: ValueItemType,
importData: ImportDataType | undefined,
eachIndex?: number
) => indexData[prop];
break;
case 2:
keyTemplate.render = (
indexData: any,
value: ValueItemType,
importData: ImportDataType | undefined,
eachIndex?: number
) => importData?.[prop];
break;
case 3:
keyTemplate.render = ((
indexData: any,
value: ValueItemType,
importData: ImportDataType | undefined,
eachIndex?: number
) => eachIndex) as any;
break;
default:
keyTemplate.render = ((
indexData: any,
value: ValueItemType,
importData: ImportDataType | undefined,
eachIndex?: number
) => undefined) as any;
break;
}
} else {
switch (val.originType) {
case 1:
keyTemplate.render = (
indexData: any,
value: ValueItemType,
importData: ImportDataType | undefined,
eachIndex?: number
) => (renderVal as any)(indexData);
break;
case 2:
keyTemplate.render = (
indexData: any,
value: ValueItemType,
importData: ImportDataType | undefined,
eachIndex?: number
) => (renderVal as any)(importData);
break;
case 3:
keyTemplate.render = ((
indexData: any,
value: ValueItemType,
importData: ImportDataType | undefined,
eachIndex?: number
) => eachIndex) as any;
break;
default:
keyTemplate.render = ((
indexData: any,
value: ValueItemType,
importData: ImportDataType | undefined,
eachIndex?: number
) => undefined) as any;
break;
}
}
}
} else {
for (const txt of keyArr) {
const val = createValItem(getVal(txt));
Expand Down

0 comments on commit 4b59c23

Please sign in to comment.