Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unspecified error on Internet Explorer in an iframe with document.activeElement #193

Closed
michaelwnelson opened this issue Aug 9, 2017 · 1 comment

Comments

@michaelwnelson
Copy link
Contributor

This was brought up as an issue in VueJS as well.

In short, when inside an iframe in Internet Explorer, the document.activeElement check causes an unspecified error. Here is a screenshot of the error in the console:
Image of Internet Explorer Error

It appears it has been resolved as an Internet Explorer bug recently However, it would appear this could also be addressed without waiting on an Internet Explorer update for users.

As benvirus' comment points out, it appears this can be address by changing the logic to check for document.activeElement to something along these lines:

try {
    return document.activeElement !== elm && elm.value !== checkVal
} catch (e) {
    return true;
}
@michaelwnelson
Copy link
Contributor Author

michaelwnelson commented Aug 9, 2017

After more research, it appears this can be mitigated by updating the check on window.document.activeElement.

I logged out window.document to find activeElement labeled as Permission denied.
Permission Denied

I was curious how this resolved, so I logged out typeof window.document.activeElement and, surprisingly, it resolved to a type I did not know existed, unknown.

Here is my console.log() from my editor:
Image of console.log

And here is the associated output in Internet Explorer:
Image of Internet Explorer log output

Apparently, typeof value: unknown is recognized in IEs >=8 , see: http://stackoverflow.com/a/10982960/369687.

Therefore, I suggest updating the casted boolean check of canUseActiveElement from:

var canUseActiveElement = !!(typeof window !== 'undefined' && window.document && typeof window.document.activeElement);

To:

var canUseActiveElement = !!(typeof window !== 'undefined' && window.document && typeof window.document.activeElement !== 'unknown');

@danez danez closed this as completed in #194 Sep 4, 2017
danez pushed a commit that referenced this issue Sep 4, 2017
* Fix activeElement check #193

* Add test and fix check
danez pushed a commit that referenced this issue Sep 5, 2017
* Fix activeElement check #193

* Add test and fix check
danez pushed a commit that referenced this issue Sep 5, 2017
* Fix activeElement check #193

* Add test and fix check
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant