diff options
Diffstat (limited to 'src/js/utils.js')
-rw-r--r-- | src/js/utils.js | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/js/utils.js b/src/js/utils.js index a7d2ada4..109de031 100644 --- a/src/js/utils.js +++ b/src/js/utils.js @@ -831,6 +831,13 @@ const utils = { return fragment.firstChild.innerText; }, + // Like outerHTML, but also works for DocumentFragment + getHTML(element) { + const wrapper = document.createElement('div'); + wrapper.appendChild(element); + return wrapper.innerHTML; + }, + // Get aspect ratio for dimensions getAspectRatio(width, height) { const getRatio = (w, h) => (h === 0 ? w : getRatio(h, w % h)); |