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")
{
let companent = RenderCompanent(data);
elem = RenderElement(null, companent)
elem = RenderCompanentScope(null, companent)
}
else if(typeof data.companent == "string")
{
@ -88,7 +88,7 @@
}
else
{
RenderElement(elem, companent);
RenderCompanentScope(elem, companent);
}
}
}
@ -127,7 +127,7 @@
}
else
{
RenderElement(elem, companent)
RenderCompanentScope(elem, companent)
}
}
}else{
@ -139,7 +139,7 @@
}
else
{
RenderElement(elem, companent)
RenderCompanentScope(elem, companent)
}
}
}
@ -151,14 +151,14 @@
if(parent)
{
for (const vdata of data.flat(Infinity)) {
RenderElement(parent, vdata)
RenderCompanentScope(parent, vdata)
};
}
else
{
let d = document.createDocumentFragment();
for (const vdata of data.flat(Infinity)) {
RenderElement(d, vdata)
RenderCompanentScope(d, vdata)
};
elem = d;
}
@ -178,13 +178,42 @@
}
}
function RenderCompanent(data)
function RenderCompanentScope(data)
{
useCompanent(data);
let result = data.companent(data.props);
useCompanent(undefined);
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)
{
if(a instanceof Array)
@ -228,11 +257,15 @@
case "in":{
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{
props.children = [
é(a[index])
]
let child = é(a[index]);
child.parent = t;
props.children = [child]
}
break
};
@ -296,7 +329,8 @@
if(!Object.is(newValue, value))
{
companent._state[id] = value;
return companent._render = true;
companent._render = true;
scheduleRenderCompanent(companent);
}
}
]