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.
1 parent 27c47f3 commit a39c43aCopy full SHA for a39c43a
ts/adaptors/HTMLAdaptor.ts
@@ -199,6 +199,13 @@ export class HTMLAdaptor<
199
extends AbstractDOMAdaptor<N, T, D>
200
implements MinHTMLAdaptor<N, T, D>
201
{
202
+
203
+ /**
204
+ * The font size to use when it can't be measured (e.g., the element
205
+ * isn't in the DOM).
206
+ */
207
+ public static DEFAULT_FONT_SIZE = 16;
208
209
/**
210
* The HTML adaptor can measure DOM node sizes
211
*/
@@ -588,7 +595,10 @@ export class HTMLAdaptor<
588
595
589
596
public fontSize(node: N) {
590
597
const style = this.window.getComputedStyle(node);
591
- return parseFloat(style.fontSize);
598
+ return parseFloat(
599
+ style.fontSize ||
600
+ String((this.constructor as typeof HTMLAdaptor).DEFAULT_FONT_SIZE)
601
+ );
592
602
}
593
603
594
604
0 commit comments