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

Make safe extension properly handle scriptlevel of 0. (mathjax/MathJax#2745) #768

Merged
merged 1 commit into from
Feb 22, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions ts/ui/safe/SafeMethods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -242,31 +242,31 @@ export const SafeMethods: {[name: string]: FilterFunction<any, any, any>} = {
*
* @param {Safe<N,T,D>} safe The Safe object being used
* @param {string} size The script size multiplier to test
* @return {number} The sanitized size
* @return {string} The sanitized size
*
* @template N The HTMLElement node class
* @template T The Text node class
* @template D The Document class
*/
filterSizeMultiplier<N, T, D>(safe: Safe<N, T, D>, size: string): number {
filterSizeMultiplier<N, T, D>(safe: Safe<N, T, D>, size: string): string {
const [m, M] = safe.options.scriptsizemultiplierRange || [-Infinity, Infinity];
return Math.min(M, Math.max(m, parseFloat(size)));
return Math.min(M, Math.max(m, parseFloat(size))).toString();
},

/**
* Filter scriptLevel
*
* @param {Safe<N,T,D>} safe The Safe object being used
* @param {string} size The scriptlevel to test
* @return {number|null} The sanitized scriptlevel or null
* @return {string|null} The sanitized scriptlevel or null
*
* @template N The HTMLElement node class
* @template T The Text node class
* @template D The Document class
*/
filterScriptLevel<N, T, D>(safe: Safe<N, T, D>, level: string): number | null {
filterScriptLevel<N, T, D>(safe: Safe<N, T, D>, level: string): string | null {
const [m, M] = safe.options.scriptlevelRange || [-Infinity, Infinity];
return Math.min(M, Math.max(m, parseInt(level)));
return Math.min(M, Math.max(m, parseInt(level))).toString();
},

/**
Expand Down