Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix zero in text node #46

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from

Conversation

tpresley
Copy link

@tpresley tpresley commented Jun 1, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Span with value zero can break application
2 participants