Skip to content

Commit 51d062b

Browse files
committed
0.2.0-alpha.15
1 parent f998b17 commit 51d062b

File tree

3 files changed

+19
-4
lines changed

3 files changed

+19
-4
lines changed

apps/vite/src/app.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
import { 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+
*/

deno.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
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",

lib/tags.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff 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)

0 commit comments

Comments
 (0)