van
van copied to clipboard
Cannot update dom when initial state is undefined or null
const s = van.state();
van.add(document.body, van.tags.div(() => s.val));
s.val = 'new';
The initial s.val is undefined, so vanjs won't create a DOM to bind with the state.
Maybe creating an empty TextNode is a solution.
This is intended behavior. Because in the binding function for a child DOM node, returning undefined or null means you want to delete that node. See the Removing a DOM node section in VanJS tutorial.