document.contains does not work in IE 11
See original GitHub issueBug 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>;
- 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:
- Created 3 years ago
- Reactions:1
- Comments:8 (7 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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.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.