Skip to content

Commit

Permalink
Make safe extension properly handle scriptlevel of 0. (mathjax/MathJa…
Browse files Browse the repository at this point in the history
  • Loading branch information
dpvc committed Jan 31, 2022
1 parent 6b38558 commit 77f1a3b
Showing 1 changed file with 6 additions and 6 deletions.
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

0 comments on commit 77f1a3b

Please sign in to comment.