Skip to content

Commit 396ef6d

Browse files
ikhsanalatsaryExilz
authored andcommitted
fix(): img dimension cause crash
solve meliorence#120
1 parent af75947 commit 396ef6d

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

src/HTMLImage.js

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,24 @@ export default class HTMLImage extends PureComponent {
4949
if (width) {
5050
styleWidth = width;
5151
}
52-
style.forEach((styles) => {
53-
if (!width && styles['width']) {
54-
styleWidth = styles['width'];
52+
if (Array.isArray(style)) {
53+
style.forEach((styles) => {
54+
if (!width && styles['width']) {
55+
styleWidth = styles['width'];
56+
}
57+
if (!height && styles['height']) {
58+
styleHeight = styles['height'];
59+
}
60+
});
61+
} else {
62+
if (!width && style['width']) {
63+
styleWidth = style['width'];
5564
}
56-
if (!height && styles['height']) {
57-
styleHeight = styles['height'];
65+
if (!height && style['height']) {
66+
styleHeight = style['height'];
5867
}
59-
});
68+
}
69+
6070
return { styleWidth, styleHeight };
6171
}
6272

0 commit comments

Comments
 (0)