From 644985c8e35a775b120e4b6ba45639a6e5e8fa36 Mon Sep 17 00:00:00 2001 From: Bryan Housel Date: Sun, 13 May 2018 12:57:49 -0400 Subject: [PATCH] Don't write 'undefined' to storage when deleting the changeset source (closes #5012) Also includes some code to ignore/remove any 'undefined' source values which happen to be stored in localStorage. Because the saved source/comment/hashtags expire after 2 days, this code can go away in iD v2.9 --- modules/ui/commit.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/modules/ui/commit.js b/modules/ui/commit.js index 9fa7e1007..3b934898c 100644 --- a/modules/ui/commit.js +++ b/modules/ui/commit.js @@ -79,9 +79,13 @@ export function uiCommit(context) { tags.hashtags = hashtags; } + // iD 2.8.1 could write a literal 'undefined' here.. see #5021 + // (old source values expire after 2 days, so 'undefined' checks can go away in v2.9) var source = context.storage('source'); - if (source) { + if (source && source !== 'undefined') { tags.source = source; + } else if (source === 'undefined') { + context.storage('source', null); } _changeset = new osmChangeset({ tags: tags }); @@ -297,7 +301,9 @@ export function uiCommit(context) { } } if (changed.hasOwnProperty('source')) { - if (!onInput) { + if (changed.source === undefined) { + context.storage('source', null); + } else if (!onInput) { context.storage('source', changed.source); context.storage('commentDate', Date.now()); }