Skip to content

Conversation

@jackwh
Copy link

@jackwh jackwh commented Apr 4, 2024

I noticed an issue in Filament which caused Alpine to crash due to a component inadvertently setting undefined as a value with $persist. Whilst debugging I found a recent PR #4091, which attempts to prevent a similar issue when retrieving an undefined value from storage.

However it seems users can still unintentionally persist an undefined value, which confusingly gets stringified to remain undefined before then being saved as a string regardless by localStorage setItem.

This PR prevents committing undefined to storage by swapping it out with null, which is valid JSON and can therefore be stringified. Future checks with storageHas will return false (as expected), falling back to the initial value. It might be worth raising a warning but I'll take any feedback on this approach first. Thanks!

@calebporzio
Copy link
Collaborator

Thanks @jackwh - can you provide a simple code snippet to demonstrate this problem? or better include a test for this?

@calebporzio
Copy link
Collaborator

Closing because of lack of response. Please re-submit if new info is presented. Thanks!

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