We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 806f2af + 85d8430 commit d0510caCopy full SHA for d0510ca
ts/adaptors/HTMLAdaptor.ts
@@ -199,6 +199,12 @@ export class HTMLAdaptor<
199
extends AbstractDOMAdaptor<N, T, D>
200
implements MinHTMLAdaptor<N, T, D>
201
{
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
+
208
/**
209
* The HTML adaptor can measure DOM node sizes
210
*/
@@ -588,7 +594,10 @@ export class HTMLAdaptor<
588
594
589
595
public fontSize(node: N) {
590
596
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
+ );
592
601
}
593
602
603
0 commit comments