aboutsummaryrefslogtreecommitdiffstats
path: root/src/js/utils/elements.js
diff options
context:
space:
mode:
authorSam Potts <sam@potts.es>2018-06-17 00:40:28 +1000
committerGitHub <noreply@github.com>2018-06-17 00:40:28 +1000
commitccc2608cf62f1406c3d626ed8dbd31f1acd714ce (patch)
tree0881e678c29c6e147c254b10f490768858df673a /src/js/utils/elements.js
parentde45de0e0bbfdea63977427d70fea503274e39b6 (diff)
parent115f352ade7fbe133a42fd434dbcc1fca13287a7 (diff)
downloadplyr-ccc2608cf62f1406c3d626ed8dbd31f1acd714ce.tar.lz
plyr-ccc2608cf62f1406c3d626ed8dbd31f1acd714ce.tar.xz
plyr-ccc2608cf62f1406c3d626ed8dbd31f1acd714ce.zip
Merge pull request #1039 from friday/poster-race-conditions
Fix poster race conditions
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