Cache window.ShadowDOMPolyfill value in closures

This avoids unnecessary references properties on window, which are
slow to look up.

Noticed this when looking at a CPU profile of the code review tool.