Uses document.contains to figure if element exists in the DOM

As stated in the commit message, this PR tries to address the issue raised in [https://github.com/Polymer/ShadowDOM/issues/365](https://github.com/Polymer/ShadowDOM/issues/365).

According to a commenter, `document.contains` is in the happy path so performance shouldn't worsen. I'm sure there are other considerations I'm not aware of.
Looking for feedback on the feasibility of this change, thank you.