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

Prevent bad date causing exception on console. #105

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mlawlerau
Copy link

Using this lib on my svelte 5 app I encountered a problem with this line. Is this ok to contribute?

@mlawlerau
Copy link
Author

mlawlerau commented Nov 24, 2024

Im passing/binding a date object ala:

let date = $state(new Date())
...

<form>
<div class="pt-[3px] pl-1">
    <DateInput id="date" bind:value={date} placeholder="" timePrecision={null} format="yyyy-MM-dd"/>
</div>
<input hidden name="date" bind:value={date} />
</form>

Then after my form has succeeded, when the resulting page renders i get:

TypeError: date.getTime is not a function. (In 'date.getTime()', 'date.getTime' is undefined)

Which I can track to that particular line. I see the test for null and undefined above it. But if I add that test for false, then it works.

Any suggestions on how to debug this or fix at my application level so I dont need my submitted change?

@mlawlerau mlawlerau changed the title Prevent undefined date causing exception on console. Prevent empty date causing exception on console. Nov 24, 2024
@mlawlerau mlawlerau changed the title Prevent empty date causing exception on console. Prevent bad date causing exception on console. Nov 24, 2024
@probablykasper
Copy link
Owner

Could you create a REPL?

@mlawlerau
Copy link
Author

I am using a flowbite-svelte modal and I cant see any REPL examples that show using it. Any ideas?

@probablykasper
Copy link
Owner

Not sure what you mean? If you create a REPL (https://svelte.dev/playground/hello-world?version=5.2.8) that would help me understand what exactly the issue is and whether this is the proper solution

@mlawlerau
Copy link
Author

Yeah, I understand the idea of a REPL to provide a minimal demo of the issue. I tried to do one, but my app uses flowbite-svelte and as soon as I tried to add that import for the Modal component, the REPL got an error. I searched for other REPLs using flowbite-svelte and could not find any. I will try to see if I can make a trivial example that illustrates the issue. I do know that that condition I added to the if test line solves my problem (I have copied the source into my project for the time being, but would prefer to depend on your release, rather than maintaining an internal fork inside my app.).

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.

2 participants