Fix for chid.value is undefined

This commit is contained in:
piotrpekala7 2020-06-08 11:58:11 +02:00
parent 672d25132f
commit eb9102769c
3 changed files with 6 additions and 6 deletions

View File

@ -18,21 +18,21 @@ export class StylesToFontConverter implements Converter<string, Font> {
});
ast.children.forEach(child => {
if (child.property === 'font-size') {
if (child.property === 'font-size' && child.value && child.value.children) {
child.value.children.forEach(value => {
if (value.type === 'Dimension') {
font.font_size = parseInt(value.value);
}
});
}
if (child.property === 'font-family') {
if (child.property === 'font-family' && child.value && child.value.children) {
child.value.children.forEach(value => {
if (value.type === 'Identifier') {
font.font_family = value.name;
}
});
}
if (child.property === 'font-weight') {
if (child.property === 'font-weight' && child.value && child.value.children) {
child.value.children.forEach(value => {
if (value.type === 'Identifier') {
font.font_weight = value.name;

View File

@ -11,7 +11,7 @@ export class CssFixer {
// fixes font-size when unit (pt|px) is not defined
ast.children.forEach(child => {
if (child.property === 'font-size') {
if (child.property === 'font-size' && child.value && child.value.children) {
child.value.children.forEach(value => {
if (value.type === 'Number') {
const fontSize = value.value.toString();

View File

@ -30,7 +30,7 @@ export class FontFixer {
let isByIdentifier = true;
ast.children.forEach(child => {
if (child.property === 'font-family') {
if (child.property === 'font-family' && child.value && child.value.children) {
child.value.children.forEach(value => {
if (value.type === 'Identifier') {
fontFamilyPointer = value;
@ -41,7 +41,7 @@ export class FontFixer {
}
});
}
if (child.property === 'font-size') {
if (child.property === 'font-size' && child.value && child.value.children) {
child.value.children.forEach(value => {
if (value.type === 'Dimension') {
fontSizePointer = value;