Skip to content

Commit d0510ca

Browse files
authored
Merge pull request #1380 from mathjax/issue3458
Use a default font size when it can't be computed directly. (mathjax/MathJax#3458)
2 parents 806f2af + 85d8430 commit d0510ca

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

ts/adaptors/HTMLAdaptor.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,12 @@ export class HTMLAdaptor<
199199
extends AbstractDOMAdaptor<N, T, D>
200200
implements MinHTMLAdaptor<N, T, D>
201201
{
202+
/**
203+
* The font size to use when it can't be measured (e.g., the element
204+
* isn't in the DOM).
205+
*/
206+
public static DEFAULT_FONT_SIZE = 16;
207+
202208
/**
203209
* The HTML adaptor can measure DOM node sizes
204210
*/
@@ -588,7 +594,10 @@ export class HTMLAdaptor<
588594
*/
589595
public fontSize(node: N) {
590596
const style = this.window.getComputedStyle(node);
591-
return parseFloat(style.fontSize);
597+
return parseFloat(
598+
style.fontSize ||
599+
String((this.constructor as typeof HTMLAdaptor).DEFAULT_FONT_SIZE)
600+
);
592601
}
593602

594603
/**

0 commit comments

Comments
 (0)