Skip to content

🐛 Fix HTML report sorting order storage in jQuery unload event#1066

Merged
nedbat merged 1 commit intocoveragepy:masterfrom
tiangolo:fix-html-jquery-unload
Dec 6, 2020
Merged

🐛 Fix HTML report sorting order storage in jQuery unload event#1066
nedbat merged 1 commit intocoveragepy:masterfrom
tiangolo:fix-html-jquery-unload

Conversation

@tiangolo
Copy link
Copy Markdown
Contributor

🐛 Fix HTML report sorting order storage in jQuery unload event.

This is related to: #986

I'm having a (probably) similar issue. In the generated HTML report, on the console, I'm seeing an error:

Uncaught TypeError: $(...).unload is not a function
    at HTMLDocument.coverage.index_ready (coverage_html.js:227)
    at mightThrow (jquery.min.js:2)
    at process (jquery.min.js:2)

Using $().unload was deprecated and removed in jQuery 3. The recommendation is to use $().on("unload", handler).

I see that it seems the included minified jQuery JS file says it has version 1.11: https://github.com/nedbat/coveragepy/blob/master/coverage/htmlfiles/jquery.min.js#L1

Nevertheless, when I generate an HTML report from scratch in a local project, the minified jQuery I get is indeed 3.x. I have no idea why.

Either way, the method with $().on("unload", handler) works with both versions.

For completeness, I'm on Chrome, on Ubuntu.

@nedbat
Copy link
Copy Markdown
Member

nedbat commented Dec 6, 2020

Thanks for the detailed report. How did you install coverage? I have a feeling the jQuery version difference is because you installed with an Ubuntu package rather than with pip install, is that right?

@nedbat nedbat added html bug Something isn't working labels Dec 6, 2020
@nedbat nedbat merged commit b12a97e into coveragepy:master Dec 6, 2020
@tiangolo tiangolo deleted the fix-html-jquery-unload branch December 8, 2020 16:10
@tiangolo
Copy link
Copy Markdown
Contributor Author

tiangolo commented Dec 8, 2020

Not really, I installed through pytest-cov, with Fllit (equivalent to with pip), in a virtual environment.

Thanks for reviewing and merging!

@nedbat
Copy link
Copy Markdown
Member

nedbat commented Dec 19, 2020

This is now released as part of coverage 5.3.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working html

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants