Bind event listeners to the shadow root if a component is being rendered into one

Related discussion is in #840.