indoc_patch.js 484 B

1234567891011121314151617181920212223
  1. // PhantomJS always return false when using Element.contains
  2. // on a comment node - so we have to patch the inDoc util
  3. // function when running in PhantomJS.
  4. var _ = require('../../../src/util')
  5. var inDoc = _.inDoc
  6. _.inDoc = function (el) {
  7. if (el && el.nodeType === 8) {
  8. return manualInDoc(el)
  9. }
  10. return inDoc(el)
  11. }
  12. function manualInDoc (el) {
  13. while (el) {
  14. if (el === document.documentElement) {
  15. return true
  16. }
  17. el = el.parentNode
  18. }
  19. return false
  20. }