rework <slot/>

This commit is contained in:
CoolElectronics 2024-01-30 10:45:39 -05:00
parent b424342d64
commit 3cd8372c08
No known key found for this signature in database
GPG key ID: F63593D168636C50
3 changed files with 4 additions and 5 deletions

1
AliceJS.d.ts vendored
View file

@ -33,4 +33,5 @@ interface Element {
type DLComponent<T> = {
css: DLCSS,
root: Element,
children: Element[],
} & T;

View file

@ -1,2 +0,0 @@
(()=>{Object.assign(window,{css:f,rule:d,styled:{new:f,rule:d}});function u(t,o){let r=document.implementation.createHTMLDocument(""),n=document.createElement("style");r.body.appendChild(n);let s="";n.textContent=o;for(let e of n.sheet.cssRules)e.selectorText=e.selectorText.includes("self")?`.${t}.self${e.selectorText.replace("self","")}`:`.${t} ${e.selectorText}`,s+=`${e.cssText}
`;return s}function p(t,o,r){let n=`dream-${Array(16).fill(0).map(()=>Math.floor(Math.random()*16).toString(16)).join("")}`,s=document.createElement("style");document.head.appendChild(s);let e=[];for(let c in t)if(e.push(t[c]),o[c]){let i=o[c];if(isAJSReferences(i)){let m=e.length,a;handle(i,x=>{e[m]=String(x);let l=e.join("");l!=a&&(r?s.textContent=u(n,l):s.textContent=`.${n} { ${l}; }`),a=l})}else e.push(String(i))}return r?s.textContent=u(n,e.join("")):s.textContent=`.${n} { ${e.join("")}; }`,n}function d(t,...o){return p(t,o,!1)}function f(t,...o){return p(t,o,!0)}})();

6
js.js
View file

@ -165,12 +165,12 @@ export function h(type, props, ...children) {
}
Object.assign(newthis, props);
let slot = [];
newthis.children = [];
for (const child of children) {
JSXAddChild(child, slot.push.bind(slot));
JSXAddChild(child, newthis.children.push.bind(slot));
}
let elm = type.apply(newthis, [slot]);
let elm = type.apply(newthis);
elm.$ = newthis;
newthis.root = elm;
if (newthis.css) {