Skip to content

Conversation

@mgol
Copy link
Member

@mgol mgol commented Jun 29, 2023

Summary

Both IE & Edge Legacy need the workaround of calling setDocument() in an unload handler to avoid "permission denied" errors. However, due to not being possible to feature-detect this issue, the handler has been applied in all browsers for windows different than the one in which jQuery was loaded.

jQuery 4.0, which drops Edge Legacy support, guards this workaround with a document.documentMode check. This won't work in the 3.x line due to still supporting Edge Legacy but we can check for
document.documentElement.msMatchesSelector instead as that API is supported in IE 9+ and all Edge Legacy versions.

Fixes gh-5281
Ref gh-4792

+6 bytes

Checklist

Both IE & Edge Legacy need the workaround of calling `setDocument()` in an
`unload` handler to avoid "permission denied" errors. However, due to not being
possible to feature-detect this issue, the handler has been applied in all
browsers for windows different than the one in which jQuery was loaded.

jQuery 4.0, which drops Edge Legacy support, guards this workaround with
a `document.documentMode` check. This won't work in the 3.x line due to still
supporting Edge Legacy but we can check for
`document.documentElement.msMatchesSelector` instead as that API is supported
in IE 9+ and all Edge Legacy versions.

Fixes jquerygh-5281
Ref jquerygh-4792
@mgol mgol added Selector Needs review Discuss in Meeting Reserved for Issues and PRs that anyone would like to discuss in the weekly meeting. labels Jun 29, 2023
@mgol mgol self-assigned this Jun 29, 2023
@mgol mgol linked an issue Jun 29, 2023 that may be closed by this pull request
@mgol
Copy link
Member Author

mgol commented Jun 29, 2023

Test case showing all supported aliases of matches: https://output.jsbin.com/lawacad/1. In Edge 15-18 this includes matches, webkitMatchesSelector and msMatchesSelector.

@mgol mgol added this to the 3.7.1 milestone Jun 29, 2023
@timmywil timmywil removed the Discuss in Meeting Reserved for Issues and PRs that anyone would like to discuss in the weekly meeting. label Jul 10, 2023
@mgol mgol merged commit 87467a6 into jquery:3.x-stable Jul 10, 2023
@mgol mgol deleted the limit-unload-handler branch July 10, 2023 16:25
@mgol mgol removed the Needs review label Jul 10, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 24, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Development

Successfully merging this pull request may close these issues.

Iframes Memory Leak with jQuery and Sizzle

2 participants