mmistakes / minimal-mistakes

:triangular_ruler: Jekyll theme for building a personal site, blog, project documentation, or portfolio.
https://mmistakes.github.io/minimal-mistakes/
MIT License
12.43k stars 25.62k forks source link

Javascript error when pages containing TOC are resized #2140

Closed deepfriedbrain closed 5 years ago

deepfriedbrain commented 5 years ago

Environment

Expected behavior

If any page that contains a TOC is resized, the following Javascript error is thrown in the console:

main.min.js:9 Uncaught TypeError: Cannot read property 'sort' of undefined
    at i (main.min.js:9)
    at main.min.js:9

I'm using the default version of the theme (no fork), and have not modified main.min.js. I'm using Chrome 74.x (latest version).

mmistakes commented 5 years ago

Not seeing this on the demo site (for example this page doesn't have a TOC and I see no JavaScript errors in the console on resize).

Do you have a reproducible test case repository?

deepfriedbrain commented 5 years ago

I think you misread my post. It appears on pages that have TOC. I can reproduce it on the demo site.

Refer to this page: https://mmistakes.github.io/minimal-mistakes/layout-table-of-contents-post/

mmistakes commented 5 years ago

OK. I'm able to reproduce. When I rolled back jQuery the other day and uglified the scripts there were a few warnings related to the Gumshoe and scroll scripts. Perhaps something is getting mangled there when everything is concatenated.

Will have to play around.

mmistakes commented 5 years ago

It's Gumshoe related. When I use the unconcatenated versions of the scripts the error has more context.

TypeError: contents is undefined[Learn More] gumshoe.js:111:3
    sortContents http://127.0.0.1:4000/test/assets/js/plugins/gumshoe.js:111
    timeout http://127.0.0.1:4000/test/assets/js/plugins/gumshoe.js:412
mmistakes commented 5 years ago

Updating Gumshoe to v5.1.1 seems to have fixed it.

deepfriedbrain commented 5 years ago

Thank you. Was the jquery change from minified version to the full version intentional?

mmistakes commented 5 years ago

Yes. The uglify script I run minifies all the JavaScript when it concatenates. It does a better job of that if you run it on unminified code first... shaved about 2k off the file size.

deepfriedbrain commented 5 years ago

Yes, makes sense. I just wanted to confirm. The error has been resolved. Thanks!

BTW, I did notice that the jquery.min.js has been left in eventhough it's not used.