Skip to content
Open
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: 11 additions & 1 deletion ts/adaptors/HTMLAdaptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,13 @@ export class HTMLAdaptor<
extends AbstractDOMAdaptor<N, T, D>
implements MinHTMLAdaptor<N, T, D>
{

/**
* The font size to use when it can't be measured (e.g., the element
* isn't in the DOM).
*/
public static DEFAULT_FONT_SIZE = 16;

/**
* The HTML adaptor can measure DOM node sizes
*/
Expand Down Expand Up @@ -588,7 +595,10 @@ export class HTMLAdaptor<
*/
public fontSize(node: N) {
const style = this.window.getComputedStyle(node);
return parseFloat(style.fontSize);
return parseFloat(
style.fontSize ||
String((this.constructor as typeof HTMLAdaptor).DEFAULT_FONT_SIZE)
);
}

/**
Expand Down