deep-proxy #1

Merged
SethTrowbridge merged 16 commits from deep-proxy into master 2025-02-22 17:28:43 -05:00
5 changed files with 16 additions and 7 deletions
Showing only changes of commit a009f334eb - Show all commits

6
app.js
View File

@ -12,4 +12,8 @@ const sheet = Styles({
Outline:{border:"2px solid orange"} Outline:{border:"2px solid orange"}
}); });
const el = sheet.dom.div.Button.Outline(); const el = sheet.dom.a.Button.Outline({onclick(){console.log("clicked!")}}, "Click!");
console.log(el);
van.add(document.body, el, sheet.dom.p.Outline("paragraph!"));

View File

@ -5,6 +5,6 @@
"deno.window", "deno.window",
"DOM" "DOM"
], ],
"types": ["./drill.d.ts"] "types": ["./drill.d.ts", "./types.d.ts"]
} }
} }

7
drill.d.ts vendored
View File

@ -3,10 +3,9 @@ export {}
declare global { declare global {
namespace Gale namespace Gale
{ {
type Invoker =()=>HTMLElement type Elemental<T extends string> = {[K in keyof HTMLElementTagNameMap]: Circular<T, K>}
type Elemental<T extends string> = {[K in keyof HTMLElementTagNameMap]: Circular<T>} type Circular<Keys extends string, ElementName extends keyof HTMLElementTagNameMap> = {
type Circular<Keys extends string> = { [K in Keys]: Circular<Keys, ElementName>&Van.TagFunc<HTMLElementTagNameMap[ElementName]>;
[K in Keys]: Circular<Keys>&Invoker;
}; };
} }
} }

View File

@ -5,6 +5,7 @@
<title>Document</title> <title>Document</title>
</head> </head>
<body> <body>
<script src="https://vanjs.org/code/van-1.5.3.nomodule.min.js"></script>
<script type="module" src="app.js"></script> <script type="module" src="app.js"></script>
</body> </body>
</html> </html>

View File

@ -57,7 +57,12 @@ function MakeElemental(ref)
let pending = false; let pending = false;
let classes = []; let classes = [];
const collector = new Proxy(()=>{console.log("original func invoked!", pending, classes)}, const collector = new Proxy((...args)=>{
console.log("original func invoked!", pending, classes);
const element = van.tags[pending](...args);
element.className = classes.join(" ");
return element
},
{ {
get(target, prop, rec) get(target, prop, rec)
{ {