« get me outta code hell

language: unflattenLanguageSpec: fix dropping own nodes early - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/data
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2024-12-01 20:02:07 -0400
committer(quasar) nebula <qznebula@protonmail.com>2024-12-01 20:03:06 -0400
commit8c0fa52e3356f19bfd18f035244f4f5aa88ff4b3 (patch)
treea1ea4bb667c587e1b2af7c4b3c25fd9cc199f8b8 /src/data
parentd12d22e26992f71e4edb3fdbe4f96d801ec62a24 (diff)
language: unflattenLanguageSpec: fix dropping own nodes early
recovers many strings!
Diffstat (limited to 'src/data')
-rw-r--r--src/data/language.js8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/data/language.js b/src/data/language.js
index b8f58efd..3edf7e51 100644
--- a/src/data/language.js
+++ b/src/data/language.js
@@ -110,7 +110,13 @@ export function unflattenLanguageSpec(flat, reference) {
       }
 
       if (typeof result === 'string') {
-        delete ownNode[firstKey];
+        // When an algorithm faces a corner case, don't rethink the algorithm;
+        // hard-code the right thing to do.
+        if (typeof ownNode[firstKey] === 'object' && empty(restKeys) && ownNode[firstKey]._) {
+          delete ownNode[firstKey]._;
+        } else {
+          delete ownNode[firstKey];
+        }
         return {[firstKey]: result};
       }