diff options
author | Sam Potts <sam@potts.es> | 2018-06-18 21:39:47 +1000 |
---|---|---|
committer | Sam Potts <sam@potts.es> | 2018-06-18 21:39:47 +1000 |
commit | ffd864ed39340c081adb9e4a45b3c9cfe4c139e3 (patch) | |
tree | 27eb962a678e9be7bc7e470ec087858df49263b8 /src/js/utils/elements.js | |
parent | 599883e684cf72a631ea366d0cb821fcb1c3d013 (diff) | |
download | plyr-ffd864ed39340c081adb9e4a45b3c9cfe4c139e3.tar.lz plyr-ffd864ed39340c081adb9e4a45b3c9cfe4c139e3.tar.xz plyr-ffd864ed39340c081adb9e4a45b3c9cfe4c139e3.zip |
Work on controls
Diffstat (limited to 'src/js/utils/elements.js')
-rw-r--r-- | src/js/utils/elements.js | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/js/utils/elements.js b/src/js/utils/elements.js index 69e4d46c..7b58c9ff 100644 --- a/src/js/utils/elements.js +++ b/src/js/utils/elements.js @@ -70,12 +70,19 @@ export function createElement(type, attributes, text) { // Inaert an element after another export function insertAfter(element, target) { + if (!is.element(element) || !is.element(target)) { + return; + } + target.parentNode.insertBefore(element, target.nextSibling); } // Insert a DocumentFragment export function insertElement(type, parent, attributes, text) { - // Inject the new <element> + if (!is.element(parent)) { + return; + } + parent.appendChild(createElement(type, attributes, text)); } @@ -95,6 +102,10 @@ export function removeElement(element) { // Remove all child elements export function emptyElement(element) { + if (!is.element(element)) { + return; + } + let { length } = element.childNodes; while (length > 0) { |