Skip to content

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:

  1. If it had the as-json prop, it was removed.

  2. If it's saving a string and doesn't have the as-json prop, the as-string prop was added to preserve backwards compatibility with existing saved data.

  3. 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)

Edited by Daniel Tian

Merge request reports