Skip to content

Commit

Permalink
fix(transform): merge ignore undefined new encode (#3970)
Browse files Browse the repository at this point in the history
  • Loading branch information
pearmini committed Jun 8, 2022
1 parent 74189eb commit 426d49e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
3 changes: 1 addition & 2 deletions src/transform/preprocessor/wordCloud.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { min, max } from 'd3-array';
import { indexOf } from '../../utils/array';
import { TransformComponent as TC } from '../../runtime';
import { WordCloudTransform } from '../../spec';
import { tagCloud } from '../utils/d3-cloud';
Expand Down Expand Up @@ -107,7 +106,7 @@ export const WordCloud: TC<WordCloudOptions> = (options) => {
},
);

return { data: tags, I: indexOf(tags) };
return { data: tags };
});
};

Expand Down
10 changes: 4 additions & 6 deletions src/transform/utils/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,13 @@ export function merge(
): Transform {
return async (options) => {
const newOptions = await transform(options);
const { encode: newEncode = {} } = newOptions;
const { encode: oldEncode = {} } = options;
const { encode: newEncode } = newOptions;
const { encode: oldEncode } = options;
return {
...options,
...newOptions,
encode: {
...oldEncode,
...newEncode,
},
// Update encode options only when newEncode is defined.
...(newEncode && { encode: { ...oldEncode, ...newEncode } }),
};
};
}
Expand Down

0 comments on commit 426d49e

Please sign in to comment.