[BUGFIX release]  Fix usage of document.body.contains

Closes #5088.
oops, this is just @piotrze's version without the polyfill applied.