Why Does window.exports Unexpectedly Exist?

Written by Ken Dale

We ran across an issue where window.exports was being unexpectedly set.

The cause

<div id="exports">
  ...
</div>

Why?

In some browsers, DOM elements with ids are available as variables automatically on window. When combined with functionality that checks if window.exports exists as part of environment detection there’s the potential for an issue.

See https://stackoverflow.com/questions/3434278/do-dom-tree-elements-with-ids-become-global-variables for more details.

Published September 07, 2017 by

undefined avatar
Ken Dale Github Senior Application Developer (Former)

Suggested Reading