« get me outta code hell

content: transformContent: don't bother stringifying real attributes - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2024-04-12 15:13:44 -0300
committer(quasar) nebula <qznebula@protonmail.com>2024-04-12 15:13:44 -0300
commit86d9899aa181907102b11265c74fc4aae63a7afc (patch)
treea2a38049d6210b746d00f3666b17ac3152f3602d /src
parentbcf97080272263019696296527cd8852d8d9f0ac (diff)
content: transformContent: don't bother stringifying real attributes
The main benefit of stringifying attributes like this is escaping,
which isn't needed here, since we know all the values that might
be going into it.
Diffstat (limited to 'src')
-rw-r--r--src/content/dependencies/transformContent.js9
1 files changed, 3 insertions, 6 deletions
diff --git a/src/content/dependencies/transformContent.js b/src/content/dependencies/transformContent.js
index 42790e7..f1ea957 100644
--- a/src/content/dependencies/transformContent.js
+++ b/src/content/dependencies/transformContent.js
@@ -448,13 +448,10 @@ export default {
             return getTextNodeContents(node, index);
           }
 
-          const attributes = html.attributes({
-            class: 'INSERT-NON-TEXT',
-            'data-type': node.type,
-          });
+          let attributes = `class="INSERT-NON-TEXT" data-type="${node.type}"`;
 
-          if (node.type === 'processed-image') {
-            attributes.set('data-inline', node.inline);
+          if (node.type === 'processed-image' && node.inline) {
+            attributes += ` data-inline`;
           }
 
           return `<span ${attributes}>${index}</span>`;