File tree Expand file tree Collapse file tree 3 files changed +19
-4
lines changed
Expand file tree Collapse file tree 3 files changed +19
-4
lines changed Original file line number Diff line number Diff line change 11import { Builder , ref , tags } from "@purifyjs/core" ;
22
3- const time = ref ( new Date ( ) . toLocaleString ( ) , ( set ) => {
3+ const s = ref ( "World" ) ;
4+
5+ new Builder ( document . body ) . replaceChildren$ (
6+ tags . div ( ) . replaceChildren$ ( "Hello " , s ) ,
7+ ) ;
8+
9+ /* const time = ref(new Date().toLocaleString(), (set) => {
410 const interval = setInterval(() => set(new Date().toLocaleString()), 1000);
511 return () => {
612 clearInterval(interval);
@@ -19,3 +25,4 @@ new Builder(document.body).replaceChildren$(
1925 .setAttribute("foo", "bar"),
2026 ),
2127);
28+ */
Original file line number Diff line number Diff line change 11{
22 "name" : " @purifyjs/core" ,
3- "version" : " 0.2.0-alpha.14 " ,
3+ "version" : " 0.2.0-alpha.15 " ,
44 "workspace" : [" ./apps/vite" , " ./apps/size" ],
55 "exports" : {
66 "." : " ./lib/mod.ts" ,
Original file line number Diff line number Diff line change @@ -234,14 +234,22 @@ export let Builder: BuilderConstructor = function <T extends Node & Partial<With
234234 return value ;
235235 } ;
236236
237+ // This is the best i can come up with
238+ // Normally if we had a persistent document fragment with lifecyle,
239+ // we could have just wrapped signals with it in the DOM. Not doing these at all.
240+ //
241+ // I can wrap them with an element with lifecycle and give it `display:contents`,
242+ // but that causes other issues in the dx
237243 let unwrappedArgs = args . map ( unwrap ) ;
238244 if ( hasSignal ) {
239245 let computedArgs = computed ( ( ) => args . map ( unwrap ) ) ;
240246 cleanups [ targetName ] = node . $effect ! ( ( ) =>
241- computedArgs . follow ( ( newArgs ) => ( node [ nodeName ] as Fn ) ( ...newArgs ) )
247+ computedArgs . follow ( ( newArgs ) => ( node [ nodeName ] as Fn ) ( ...newArgs ) , true )
242248 ) ;
249+ } else {
250+ ( node [ nodeName ] as Fn ) ( ...unwrappedArgs ) ;
243251 }
244- ( node [ nodeName ] as Fn ) ( ... unwrappedArgs ) ;
252+
245253 return proxy ;
246254 }
247255 : ! ( targetName in node )
You can’t perform that action at this time.
0 commit comments