snabbdom-pragma
snabbdom-pragma copied to clipboard
Fix zero in text node
Numbers in text nodes are not converted to strings, so the number zero is treated as 'falsy' by snabbdom. This can cause problems with dynamically changing values when patching the DOM.
Example:
// this works as expected
() => <div>1</div>
// renders to { children: undefined, sel: 'div', text: 1, ... }
// this does not work properly
() => <div>0</div>
// renders to { children: [{ children: undefined, sel: undefined, text: 0, ... }], sel: 'div', text: undefined, ... }
The fix in this PR just converts the results of sanitizeText to a string, which fixes the issue with numeric zero
Resolves #43