« get me outta code hell

html: standard blank() function - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2023-04-05 15:41:38 -0300
committer(quasar) nebula <qznebula@protonmail.com>2023-04-05 15:41:38 -0300
commit17f1220718f0e736723108042fc00cd5cb90070d (patch)
tree935e5cd02baab0ca20ae9c4e694a4874ce51f6bb
parent575fef166cfe915b743d89a2007e259c3fcb4904 (diff)
html: standard blank() function
For now this just returns an empty array, but if we need to make
changes later, it won't require editing all instances of blank
content!
-rw-r--r--src/content/dependencies/generateAlbumTrackList.js2
-rw-r--r--src/misc-templates.js2
-rw-r--r--src/util/html.js6
-rw-r--r--test/unit/util/html.js2
4 files changed, 8 insertions, 4 deletions
diff --git a/src/content/dependencies/generateAlbumTrackList.js b/src/content/dependencies/generateAlbumTrackList.js
index a2b03049..f2f2279d 100644
--- a/src/content/dependencies/generateAlbumTrackList.js
+++ b/src/content/dependencies/generateAlbumTrackList.js
@@ -121,6 +121,6 @@ export default {
       return html.tag(listTag, relations.itemsByTrack);
     }
 
-    return [];
+    return html.blank();
   }
 };
diff --git a/src/misc-templates.js b/src/misc-templates.js
index 651b6bce..710dbcc3 100644
--- a/src/misc-templates.js
+++ b/src/misc-templates.js
@@ -53,7 +53,7 @@ function unbound_generateChronologyLinks(currentThing, {
   const contributions = currentThing[contribKey];
 
   if (empty(contributions)) {
-    return [];
+    return html.blank();
   }
 
   if (contributions.length > 8) {
diff --git a/src/util/html.js b/src/util/html.js
index a7b44ec6..be267003 100644
--- a/src/util/html.js
+++ b/src/util/html.js
@@ -38,6 +38,10 @@ export const joinChildren = Symbol();
 // or when there are multiple children.
 export const noEdgeWhitespace = Symbol();
 
+export function blank() {
+  return [];
+}
+
 export function tag(tagName, ...args) {
   let content;
   let attributes;
@@ -408,7 +412,7 @@ export class Template {
             : item.valueOf()));
       return new Tag(null, null, contents).valueOf();
     } else {
-      return [];
+      return blank();
     }
   }
 
diff --git a/test/unit/util/html.js b/test/unit/util/html.js
index c26d53b2..9925d2da 100644
--- a/test/unit/util/html.js
+++ b/test/unit/util/html.js
@@ -29,7 +29,7 @@ t.test(`html.tag`, t => {
   let genericSlot;
   const genericTemplate = html.template(slot => {
     genericSlot = slot('title');
-    return [];
+    return html.blank();
   });
 
   // 9-10: tag treated as content, not attributes