aboutsummaryrefslogtreecommitdiffstats
path: root/src/js/utils/elements.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/js/utils/elements.js')
-rw-r--r--src/js/utils/elements.js8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/js/utils/elements.js b/src/js/utils/elements.js
index 39b944d2..2d314ed8 100644
--- a/src/js/utils/elements.js
+++ b/src/js/utils/elements.js
@@ -42,9 +42,11 @@ export function setAttributes(element, attributes) {
return;
}
- Object.entries(attributes).forEach(([key, value]) => {
- element.setAttribute(key, value);
- });
+ // Assume null and undefined attributes should be left out,
+ // Setting them would otherwise convert them to "null" and "undefined"
+ Object.entries(attributes)
+ .filter(([, value]) => !is.nullOrUndefined(value))
+ .forEach(([key, value]) => element.setAttribute(key, value));
}
// Create a DocumentFragment