Skip to content

Commit

Permalink
Ensure default field format is a new object for each field.
Browse files Browse the repository at this point in the history
  • Loading branch information
lukeelmers committed Mar 28, 2019
1 parent 8f496aa commit 2a0c802
Showing 1 changed file with 3 additions and 3 deletions.
Expand Up @@ -30,21 +30,21 @@ import { fieldFormats } from '../../../registry/field_formats';

const config = chrome.getUiSettingsClient();

const defaultFormat = { convert: identity };
const getConfig = (...args: any[]): any => config.get(...args);
const getDefaultFieldFormat = () => ({ convert: identity });

const getFieldFormat = (id: string, params: object) => {
const Format = fieldFormats.byId[id];
if (Format) {
return new Format(params, getConfig);
} else {
return defaultFormat;
return getDefaultFieldFormat();
}
};

export const getFormat = (mapping: any) => {
if (!mapping) {
return defaultFormat;
return getDefaultFieldFormat();
}
const { id } = mapping;
if (id === 'range') {
Expand Down

0 comments on commit 2a0c802

Please sign in to comment.