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

addresses issue raised in
https://github.com/Polymer/ShadowDOM/issues/365#issuecomment-33509711
Merge pull request #4263 from locks/indom-transition

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