mirror of
https://github.com/Smaug123/KaTeX
synced 2025-10-05 11:18:39 +00:00
perf: Avoid vertical-align:0em style (#3358)
Avoid emitting `vertical-align:0em` by protecting each such style setting with an `if`. Fixes #3351 Co-authored-by: ylemkimon <y@ylem.kim>
This commit is contained in:
@@ -300,7 +300,9 @@ function buildHTMLUnbreakable(children, options) {
|
||||
// falls at the depth of the expression.
|
||||
const strut = makeSpan(["strut"]);
|
||||
strut.style.height = (body.height + body.depth) + "em";
|
||||
strut.style.verticalAlign = -body.depth + "em";
|
||||
if (body.depth) {
|
||||
strut.style.verticalAlign = -body.depth + "em";
|
||||
}
|
||||
body.children.unshift(strut);
|
||||
|
||||
return body;
|
||||
@@ -394,7 +396,9 @@ export default function buildHTML(tree: AnyParseNode[], options: Options): DomSp
|
||||
if (tagChild) {
|
||||
const strut = tagChild.children[0];
|
||||
strut.style.height = (htmlNode.height + htmlNode.depth) + "em";
|
||||
strut.style.verticalAlign = (-htmlNode.depth) + "em";
|
||||
if (htmlNode.depth) {
|
||||
strut.style.verticalAlign = (-htmlNode.depth) + "em";
|
||||
}
|
||||
}
|
||||
|
||||
return htmlNode;
|
||||
|
@@ -381,8 +381,10 @@ const htmlBuilder: HtmlBuilder<"array"> = function(group, options) {
|
||||
separator.style.borderRightWidth = `${ruleThickness}em`;
|
||||
separator.style.borderRightStyle = lineType;
|
||||
separator.style.margin = `0 -${ruleThickness / 2}em`;
|
||||
separator.style.verticalAlign =
|
||||
-(totalHeight - offset) + "em";
|
||||
const shift = totalHeight - offset;
|
||||
if (shift) {
|
||||
separator.style.verticalAlign = -shift + "em";
|
||||
}
|
||||
|
||||
cols.push(separator);
|
||||
} else {
|
||||
|
@@ -47,7 +47,9 @@ defineFunction({
|
||||
// This code resolved issue #1153
|
||||
const strut = buildCommon.makeSpan(["strut"]);
|
||||
strut.style.height = (node.height + node.depth) + "em";
|
||||
strut.style.verticalAlign = -node.depth + "em";
|
||||
if (node.depth) {
|
||||
strut.style.verticalAlign = -node.depth + "em";
|
||||
}
|
||||
node.children.unshift(strut);
|
||||
|
||||
// Next, prevent vertical misplacement when next to something tall.
|
||||
|
@@ -1089,7 +1089,7 @@ exports[`Extending katex by new fonts and symbols Add new font class to new exte
|
||||
>
|
||||
<span class="base">
|
||||
<span class="strut"
|
||||
style="height:0.84425em;vertical-align:0em;"
|
||||
style="height:0.84425em;"
|
||||
>
|
||||
</span>
|
||||
<span class="mord mockEasternArabicFont-Regular">
|
||||
@@ -1170,7 +1170,7 @@ exports[`Newlines via \\\\ and \\newline \\\\ causes newline, even after mrel an
|
||||
>
|
||||
<span class="base">
|
||||
<span class="strut"
|
||||
style="height:0.68333em;vertical-align:0em;"
|
||||
style="height:0.68333em;"
|
||||
>
|
||||
</span>
|
||||
<span class="mord mathnormal"
|
||||
@@ -1208,7 +1208,7 @@ exports[`Newlines via \\\\ and \\newline \\\\ causes newline, even after mrel an
|
||||
</span>
|
||||
<span class="base">
|
||||
<span class="strut"
|
||||
style="height:0.69444em;vertical-align:0em;"
|
||||
style="height:0.69444em;"
|
||||
>
|
||||
</span>
|
||||
<span class="mord mathnormal">
|
||||
@@ -1219,7 +1219,7 @@ exports[`Newlines via \\\\ and \\newline \\\\ causes newline, even after mrel an
|
||||
</span>
|
||||
<span class="base">
|
||||
<span class="strut"
|
||||
style="height:0.43056em;vertical-align:0em;"
|
||||
style="height:0.43056em;"
|
||||
>
|
||||
</span>
|
||||
<span class="mord mathnormal">
|
||||
|
Reference in New Issue
Block a user