Clone Render element

This commit is contained in:
Abdussamed ULUTAŞ 2023-01-22 17:23:53 +03:00
parent 8ad90af4b1
commit 0a351a51f1
1 changed files with 46 additions and 12 deletions

58
core.js
View File

@ -68,7 +68,7 @@
else if(typeof data.companent == "function") else if(typeof data.companent == "function")
{ {
let companent = RenderCompanent(data); let companent = RenderCompanent(data);
elem = RenderElement(null, companent) elem = RenderCompanentScope(null, companent)
} }
else if(typeof data.companent == "string") else if(typeof data.companent == "string")
{ {
@ -88,7 +88,7 @@
} }
else else
{ {
RenderElement(elem, companent); RenderCompanentScope(elem, companent);
} }
} }
} }
@ -127,7 +127,7 @@
} }
else else
{ {
RenderElement(elem, companent) RenderCompanentScope(elem, companent)
} }
} }
}else{ }else{
@ -139,7 +139,7 @@
} }
else else
{ {
RenderElement(elem, companent) RenderCompanentScope(elem, companent)
} }
} }
} }
@ -151,14 +151,14 @@
if(parent) if(parent)
{ {
for (const vdata of data.flat(Infinity)) { for (const vdata of data.flat(Infinity)) {
RenderElement(parent, vdata) RenderCompanentScope(parent, vdata)
}; };
} }
else else
{ {
let d = document.createDocumentFragment(); let d = document.createDocumentFragment();
for (const vdata of data.flat(Infinity)) { for (const vdata of data.flat(Infinity)) {
RenderElement(d, vdata) RenderCompanentScope(d, vdata)
}; };
elem = d; elem = d;
} }
@ -178,13 +178,42 @@
} }
} }
function RenderCompanent(data) function RenderCompanentScope(data)
{ {
useCompanent(data); useCompanent(data);
let result = data.companent(data.props); let result = data.companent(data.props);
useCompanent(undefined); useCompanent(undefined);
return result; return result;
};
function clone(original)
{
if(Array.isArray(original))
{
let e = [];
for (const original of original) {
// Klonlanabilirlik
}
}
} }
function checkSyncRender(data)
{
// İki kompanentin farkına bakılmalı ve yeniden çizilmeleri gerekiyor
}
function scheduleRender(data)
{
if(scheduleRender.planned)
{
scheduleRender.items.push(data);
return;
};
requestAnimationFrame(()=>{
scheduleRender.planned = false;
checkSyncRender(data)
});
scheduleRender.planned = true;
};
scheduleRender.planned = false;
scheduleRender.items = [];
function é(a,b) function é(a,b)
{ {
if(a instanceof Array) if(a instanceof Array)
@ -228,11 +257,15 @@
case "in":{ case "in":{
if(a[index] instanceof Array) if(a[index] instanceof Array)
{ {
props.children = a[index].map(é); props.children = a[index].map((child) => {
let item = é(child);
item.parent = t;
return item;
});
}else{ }else{
props.children = [ let child = é(a[index]);
é(a[index]) child.parent = t;
] props.children = [child]
} }
break break
}; };
@ -296,7 +329,8 @@
if(!Object.is(newValue, value)) if(!Object.is(newValue, value))
{ {
companent._state[id] = value; companent._state[id] = value;
return companent._render = true; companent._render = true;
scheduleRenderCompanent(companent);
} }
} }
] ]