« get me outta code hell

hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/util
diff options
context:
space:
mode:
Diffstat (limited to 'src/util')
-rw-r--r--src/util/html.js14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/util/html.js b/src/util/html.js
index a1d6962a..e2cbf776 100644
--- a/src/util/html.js
+++ b/src/util/html.js
@@ -190,6 +190,10 @@ export class Tag {
     this.content = content;
   }
 
+  clone() {
+    return new Tag(this.tagName, this.attributes, this.content);
+  }
+
   set tagName(value) {
     if (value === undefined || value === null) {
       this.tagName = '';
@@ -489,6 +493,12 @@ export class Template {
     this.#description = description;
   }
 
+  clone() {
+    const clone = new Template(this.#description);
+    clone.setSlots(this.#slotValues);
+    return clone;
+  }
+
   static validateDescription(description) {
     if (typeof description !== 'object') {
       throw new TypeError(`Expected object, got ${typeof description}`);
@@ -688,6 +698,10 @@ export class Template {
         return blank();
       }
 
+      if (providedValue instanceof Tag || providedValue instanceof Template) {
+        return providedValue.clone();
+      }
+
       return providedValue;
     }