Make inDom check of tooltip cross document compatible

Fixes #14483
Merge pull request #14573 from twbs/indom-check-cross-doc

Make inDom check of tooltip cross document compatible