Skip to content

Commit

Permalink
Do not mutate settings object
Browse files Browse the repository at this point in the history
  • Loading branch information
sapegin authored and quantizor committed Apr 10, 2017
1 parent b0d1a73 commit 706ef18
Showing 1 changed file with 35 additions and 15 deletions.
50 changes: 35 additions & 15 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -412,13 +412,25 @@ export function compiler(markdown, {overrides = {}} = {}) {
const key = index || '0';

if (ast.type === 'code' && ast.value) {
const preProps = get(overrides, 'pre.props', {});
const codeProps = get(overrides, 'code.props', {});
const preProps = Object.assign(
{},
get(overrides, 'pre.props', {}),
{
key
}
);

preProps.key = key;
codeProps.className = codeProps.className
? `${codeProps.className} lang-${ast.lang}`
: `lang-${ast.lang}`;
const langClassName = `lang-${ast.lang}`;
const codeBaseProps = get(overrides, 'code.props', {});
const codeProps = Object.assign(
{},
codeBaseProps,
{
className: codeBaseProps.className
? `${codeBaseProps.className} ${langClassName}`
: langClassName
}
);

return React.createElement(
get(overrides, 'pre.component', 'pre'),
Expand Down Expand Up @@ -446,16 +458,24 @@ export function compiler(markdown, {overrides = {}} = {}) {

if (ast.type === 'listItem') {
if (ast.checked === true || ast.checked === false) {
const liProps = get(overrides, 'li.props', {});

liProps.key = key;

const inputProps = get(overrides, 'input.props', {});
const liProps = Object.assign(
{},
get(overrides, 'li.props', {}),
{
key
}
);

inputProps.key = 'checkbox';
inputProps.type = 'checkbox';
inputProps.checked = ast.checked;
inputProps.readOnly = true;
const inputProps = Object.assign(
{},
get(overrides, 'input.props', {}),
{
key: 'checkbox',
type: 'checkbox',
checked: ast.checked,
readOnly: true
}
);

return React.createElement(
get(overrides, 'li.component', 'li'),
Expand Down

0 comments on commit 706ef18

Please sign in to comment.