Skip to content

Fix lazyloading - #148

Open
eliandoran wants to merge 2 commits into
isaul32:masterfrom
TriliumNext:bugfix/lazy_loading_not_working
Open

Fix lazyloading#148
eliandoran wants to merge 2 commits into
isaul32:masterfrom
TriliumNext:bugfix/lazy_loading_not_working

Conversation

@eliandoran

Copy link
Copy Markdown

It appears that the conversion to TypeScript broke the lazyloading (first introduced in #5), we noticed it in production after upgrading to 41.4.2.

Identified an older version where it used to work: 9fa8967

image

Since engine is set to katex, but katex is undefined it proceeds to render and it crashes:

image

Since the old code checked for the presence of the katex instance, it would avoid this branch and continue to the lazy loading one.

Also took a time to write a test, but it is not perfect. It successfully caught the original issue and it passes now that the issue is fixed. I can't seem to be able to write a test for lazyload since it always seems that the second test fails (some kind of leak, maybe?).

Comment thread src/utils.ts
katexRenderOptions: KatexOptions = {}
): Promise<void> {
if ( engine == 'mathjax' ) {
if ( engine == 'mathjax' && window.MathJax !== undefined ) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be global.window.MathJax

Comment thread src/utils.ts
}
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
} else if ( engine === 'katex' ) {
} else if ( engine === 'katex' && window.katex !== undefined ) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be global.window.katex

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants