Merge pull request #12214 from ahocevar/avoid-flex-layout
Do not set invalid style
This commit is contained in:
+16
-12
@@ -289,7 +289,7 @@ export const measureTextHeight = (function () {
|
|||||||
/**
|
/**
|
||||||
* @type {HTMLDivElement}
|
* @type {HTMLDivElement}
|
||||||
*/
|
*/
|
||||||
let div;
|
let measureElement;
|
||||||
return function (fontSpec) {
|
return function (fontSpec) {
|
||||||
let height = textHeights[fontSpec];
|
let height = textHeights[fontSpec];
|
||||||
if (height == undefined) {
|
if (height == undefined) {
|
||||||
@@ -303,18 +303,22 @@ export const measureTextHeight = (function () {
|
|||||||
lineHeight *
|
lineHeight *
|
||||||
(metrics.actualBoundingBoxAscent + metrics.actualBoundingBoxDescent);
|
(metrics.actualBoundingBoxAscent + metrics.actualBoundingBoxDescent);
|
||||||
} else {
|
} else {
|
||||||
if (!div) {
|
if (!measureElement) {
|
||||||
div = document.createElement('div');
|
measureElement = document.createElement('div');
|
||||||
div.innerHTML = 'M';
|
measureElement.innerHTML = 'M';
|
||||||
div.style.margin = '0 !important';
|
measureElement.style.minHeight = '0';
|
||||||
div.style.padding = '0 !important';
|
measureElement.style.maxHeight = 'none';
|
||||||
div.style.position = 'absolute !important';
|
measureElement.style.height = 'auto';
|
||||||
div.style.left = '-99999px !important';
|
measureElement.style.padding = '0';
|
||||||
|
measureElement.style.border = 'none';
|
||||||
|
measureElement.style.position = 'absolute';
|
||||||
|
measureElement.style.display = 'block';
|
||||||
|
measureElement.style.left = '-99999px';
|
||||||
}
|
}
|
||||||
div.style.font = fontSpec;
|
measureElement.style.font = fontSpec;
|
||||||
document.body.appendChild(div);
|
document.body.appendChild(measureElement);
|
||||||
height = div.offsetHeight;
|
height = measureElement.offsetHeight;
|
||||||
document.body.removeChild(div);
|
document.body.removeChild(measureElement);
|
||||||
}
|
}
|
||||||
textHeights[fontSpec] = height;
|
textHeights[fontSpec] = height;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user