Serialize and deserialize by default for LocalStorageSync component
Previously, LocalStorageSync
would save a value to localStorage
, but restore that value as the stringified version (e.g. 15 -> '15'
, [1,2,3] -> '1,2,3'
, false -> 'false'
unless the as-json
prop was used.
Because we always want to restore the original saved value rather than the stringified version, this MR "flips" the logic around so that JSON (de)serialization is done by default, the as-json
prop was removed, and a new as-string
prop was added to preserve backwards compatibility with existing strings saved to localStorage
.
All the components that use localStorage
have been updated as well using the following rules:
-
If it had the
as-json
prop, it was removed. -
If it's saving a string and doesn't have the
as-json
prop, theas-string
prop was added to preserve backwards compatibility with existing saved data. -
If manual (de)serialization was being done, it was switched to
v-model
instead.
Please see this comment for more details on the reason for this change: #357216 (comment 895997832)