Skip to content

Commit 60643d0

Browse files
committed
automatic Signal.value subscription
1 parent 1e2fe28 commit 60643d0

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

src/dom/update.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
children,
1010
} from './ish.js';
1111

12+
import { Signal } from './signals.js';
1213
import { Unsafe, assign, entries, isArray } from '../utils.js';
1314
import { PersistentFragment, diffFragment, nodes } from './persistent-fragment.js';
1415
import creator from './creator.js';
@@ -72,6 +73,10 @@ const comment_unsafe = xml => (node, value) => {
7273
comment_hole(node, PersistentFragment(fragment(value, xml)));
7374
};
7475

76+
const comment_signal = (node, value) => {
77+
comment_hole(node, value instanceof Signal ? value.value : value);
78+
};
79+
7580
const data = ({ dataset }, values) => {
7681
for (const [key, value] of entries(values)) {
7782
if (value == null) delete dataset[key];
@@ -135,7 +140,7 @@ export const update = (node, type, path, name, hint) => {
135140
if (isArray(hint)) return [path, comment_array, COMMENT_ARRAY];
136141
return hint instanceof Unsafe ?
137142
[path, comment_unsafe(node.xml), UNSAFE] :
138-
[path, comment_hole, COMMENT]
143+
[path, hint instanceof Signal ? comment_signal : comment_hole, COMMENT]
139144
;
140145
}
141146
case TEMPLATE_TEXT: return [path, directFor('textContent'), TEXT];

0 commit comments

Comments
 (0)