-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
undefined/null values shouldn't be cast to String #659
Comments
Thanks for opening an issue. We discussed a related case in #249 (comment), and I think the same situation applies here — there's really no reason why In any case, it would result in a lot of wasted code being generated. At the moment, the code that gets generated for e.g. var text_5 = createText(text_5_value = state.obj.missing);
// later, when updating
if (text_5_value !== (text_5_value = state.obj.missing)) {
text_5.data = text_5_value;
} Changing it to this, which is what would be necessary... var text_5 = createText((text_5_value = state.obj.missing) == null ? '' : text_5_value);
// later, when updating
if (text_5_value !== (text_5_value = state.obj.missing)) {
text_5.data = text_5_value == null ? '' : text_5_value;
} ...isn't desirable, even if the resulting behaviour was. So I'll close this as wontfix. |
Is it possible to override the default This would allow us to implement this behavior at runtime (without resorting to a |
In my opinion it would be more useful if null/undefined/false would result in no text node at all in
<element>{{}}</element>
, and would remove the attribute it's set to in case of<element attribute='{{}}'>
Please take a look at this demostration of "questionable" String casts: https://svelte.technology/repl?version=1.22.5&gist=a63a1bbf1dec86521bbd238699e7ffdf
The text was updated successfully, but these errors were encountered: