fixing buggy shadowRoot code

this code raises an Uncaught TypeError: Cannot read property 'call' of undefined in current versions of Chrome. 

Fixing so the logic makes more sense (and doesn't cause errors).