question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

document.contains does not work in IE 11

See original GitHub issue

Bug report

Describe the bug

Using document.contains(...) does not work in IE 11.

An easy workaround is to use document.body.contains(...) instead, so it’s not such a big of a deal 😃

Anyways, it seems like the document object does not inherit the method specified on the Node prototype, thus causing the .contains(...) call to fail. So it’s possible that other calling other methods which document inherits from Node fails too…

To Reproduce

  const ref = useRef(null);
  useEffect(() => {
    console.log(document.body.contains(ref.current)); // works fine even in IE 11
    console.log(document.contains(ref.current)); // fails in IE 11
  }, []);

  return <div ref={ref} className="container"></div>;
  1. Full repro at https://github.com/tomdohnal/document-contains-repro

Expected behavior

Using document.contains(...) should work even in IE 11.

System information

  • OS: [Windows]
  • Browser (if applies) [IE 11]
  • Version of Next.js: [9.3, 9.4]
  • Version of Node.js: not applicable…

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:8 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
tomdohnalcommented, Jun 3, 2020

So, I tried to add the document.contains polyfill but it seems to be broken in IE11. So I created a pull request in their repository which fixes it https://github.com/ljharb/document.contains/pull/12.

Nonetheless, if we want to polyfill the document.contains behaviour we either need to wait for it to be merged or use our own fork of it.

0reactions
github-actions[bot]commented, Dec 24, 2022

This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Fix web compatibility issues using document modes and the ...
Go to a site having compatibility problems, press F12 to open the F12 Developer Tools, and go to the Emulation tool. · Starting...
Read more >
Javascript document.contains not working on IE11
I'm working on a Business Catalyst site (Adobe). I need to insert a placeholder div after each row of items which another script...
Read more >
Plugin for IE not working on win10/IE11 - Okta Support
We are having an issue with getting the plugin working on IE11 running on Windows 10. ... It works perfectly in Chrome but...
Read more >
Issues Uploading Documents: Common Errors, Causes, and ...
This article will help you diagnose and resolve common issues when uploading PDFs or other document types via the DocuSign web application.
Read more >
Why is Internet Explorer IE11 not recognized in BPM 8.5 ... - IBM
IE is not able to show this kind of address. Firefox can do this.Therefore we customized control 'Document Viewer' so that it can...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found