better factoring for some utility functions
fix scope on CustomEvent shim
update ShadowDOMPolyfill usage
support sharing logFlags