This repository was archived by the owner on Apr 1, 2022. It is now read-only.

Description
I'm attempting to use this component but I'm getting the following error once I add import the module.
Cannot read property 'appendChild' of null
// Refers to https://davidwalsh.name/detect-scrollbar-width
const div = document.createElement('div')
div.style.width = '100px'
div.style.height = '100px'
div.style.overflow = 'scroll'
div.style.position = 'absolute'
div.style.top = '-9999px'
document.body.appendChild(div) /* <---- ERROR IS THIS LINE */
const SCROLLBAR_WIDTH = div.offsetWidth - div.clientWidth
My guess is that this is running before document has loaded or body doesn't exist at this stage? But why should it exist at the point of import?
I'm using this with default Rails 5.1 + Vue/webpacker setup.