Build: Don't assume the browser environment; smoke test on Node w/ jsdom

Fixes gh-1950
Since we're defining `docElem` here and in offset.js, let's make it a variable too.