Skip to content

Commit

Permalink
fix: translated images bloated with HTML component props
Browse files Browse the repository at this point in the history
fix #384

In this fix, the logic to extract images properties from passProps has
been extracted to a new local utility function.
  • Loading branch information
jsamr committed Jul 20, 2020
1 parent 4388f7b commit 9702d91
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/HTMLRenderers.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ function getTextProps(passProps) {
}
}

function getImgProps(passProps) {
const { imagesMaxWidth, imagesInitialDimensions } = passProps;
return {
imagesMaxWidth,
imagesInitialDimensions,
};
}

export function a (htmlAttribs, children, convertedCSSStyles, passProps) {
const style = _constructStyles({
tagName: 'a',
Expand Down Expand Up @@ -42,7 +50,7 @@ export function a (htmlAttribs, children, convertedCSSStyles, passProps) {
}
}

export function img (htmlAttribs, children, convertedCSSStyles, passProps = {}) {
export function img (htmlAttribs, children, convertedCSSStyles, { key, ...passProps } = {}) {
if (!htmlAttribs.src) {
return false;
}
Expand All @@ -61,7 +69,8 @@ export function img (htmlAttribs, children, convertedCSSStyles, passProps = {})
width={width}
height={height}
style={style}
{...passProps}
key={key}
{...getImgProps(passProps)}
/>
);
}
Expand Down

0 comments on commit 9702d91

Please sign in to comment.