mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-20 07:49:43 +02:00
small fixes
This commit is contained in:
@@ -64,28 +64,28 @@ function parseStyles(styles: string[]): StylesObject {
|
|||||||
const stylesObject: StylesObject = {};
|
const stylesObject: StylesObject = {};
|
||||||
for (const style of styles) {
|
for (const style of styles) {
|
||||||
const [key, value] = style.trim().split(/\s*:\s*/);
|
const [key, value] = style.trim().split(/\s*:\s*/);
|
||||||
if (key == 'radius') {
|
if (key === 'radius') {
|
||||||
if (validateNumber(value)) {
|
if (validateNumber(value)) {
|
||||||
throw new InvalidStyleError(key, value, 'number');
|
throw new InvalidStyleError(key, value, 'number');
|
||||||
}
|
}
|
||||||
stylesObject.radius = parseInt(value);
|
stylesObject.radius = parseInt(value);
|
||||||
} else if (key == 'color') {
|
} else if (key === 'color') {
|
||||||
if (validateHexCode(value)) {
|
if (validateHexCode(value)) {
|
||||||
throw new InvalidStyleError(key, value, 'hex code');
|
throw new InvalidStyleError(key, value, 'hex code');
|
||||||
}
|
}
|
||||||
stylesObject.color = value;
|
stylesObject.color = value;
|
||||||
} else if (key == 'stroke-color') {
|
} else if (key === 'stroke-color') {
|
||||||
if (validateHexCode(value)) {
|
if (validateHexCode(value)) {
|
||||||
throw new InvalidStyleError(key, value, 'hex code');
|
throw new InvalidStyleError(key, value, 'hex code');
|
||||||
}
|
}
|
||||||
stylesObject.strokeColor = value;
|
stylesObject.strokeColor = value;
|
||||||
} else if (key == 'stroke-width') {
|
} else if (key === 'stroke-width') {
|
||||||
if (validateSizeInPixels(value)) {
|
if (validateSizeInPixels(value)) {
|
||||||
throw new InvalidStyleError(key, value, 'number of pixels (eg. 10px)');
|
throw new InvalidStyleError(key, value, 'number of pixels (eg. 10px)');
|
||||||
}
|
}
|
||||||
stylesObject.strokeWidth = value;
|
stylesObject.strokeWidth = value;
|
||||||
} else {
|
} else {
|
||||||
throw new Error(`style named ${key} is unacceptable`);
|
throw new Error(`style named ${key} is not supported.`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return stylesObject;
|
return stylesObject;
|
||||||
|
Reference in New Issue
Block a user