mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-15 13:29:40 +02:00
use undefined not null
This commit is contained in:
@@ -218,7 +218,11 @@ export const drawText = function (elem, textData) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (let [i, line] of lines.entries()) {
|
for (let [i, line] of lines.entries()) {
|
||||||
if (textData.textMargin !== undefined && textData.textMargin === 0 && _textFontSize !== null) {
|
if (
|
||||||
|
textData.textMargin !== undefined &&
|
||||||
|
textData.textMargin === 0 &&
|
||||||
|
_textFontSize !== undefined
|
||||||
|
) {
|
||||||
dy = i * _textFontSize;
|
dy = i * _textFontSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -234,7 +238,7 @@ export const drawText = function (elem, textData) {
|
|||||||
if (textData.fontFamily !== undefined) {
|
if (textData.fontFamily !== undefined) {
|
||||||
textElem.style('font-family', textData.fontFamily);
|
textElem.style('font-family', textData.fontFamily);
|
||||||
}
|
}
|
||||||
if (_textFontSizePx !== null) {
|
if (_textFontSizePx !== undefined) {
|
||||||
textElem.style('font-size', _textFontSizePx);
|
textElem.style('font-size', _textFontSizePx);
|
||||||
}
|
}
|
||||||
if (textData.fontWeight !== undefined) {
|
if (textData.fontWeight !== undefined) {
|
||||||
|
@@ -421,10 +421,10 @@ describe('when parsing font sizes', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('handles undefined input', function () {
|
it('handles undefined input', function () {
|
||||||
expect(utils.parseFontSize(undefined)).toEqual([null, null]);
|
expect(utils.parseFontSize(undefined)).toEqual([undefined, undefined]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('handles unparseable input', function () {
|
it('handles unparseable input', function () {
|
||||||
expect(utils.parseFontSize({ fontSize: 14 })).toEqual([null, null]);
|
expect(utils.parseFontSize({ fontSize: 14 })).toEqual([undefined, undefined]);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@@ -962,7 +962,7 @@ export const parseFontSize = (fontSize: string | number | undefined): [number?,
|
|||||||
const fontSizeNumber = parseInt(fontSize, 10);
|
const fontSizeNumber = parseInt(fontSize, 10);
|
||||||
if (Number.isNaN(fontSizeNumber)) {
|
if (Number.isNaN(fontSizeNumber)) {
|
||||||
// if a number value can't be parsed, return null for both values
|
// if a number value can't be parsed, return null for both values
|
||||||
return [null, null];
|
return [undefined, undefined];
|
||||||
} else if (fontSize === String(fontSizeNumber)) {
|
} else if (fontSize === String(fontSizeNumber)) {
|
||||||
// if a string input doesn't contain any units, assume px units
|
// if a string input doesn't contain any units, assume px units
|
||||||
return [fontSizeNumber, fontSize + 'px'];
|
return [fontSizeNumber, fontSize + 'px'];
|
||||||
|
Reference in New Issue
Block a user