Skip to content

Commit

Permalink
Refactor object.assign -> spread apply
Browse files Browse the repository at this point in the history
To prevent needing to add a polyfill.
  • Loading branch information
quantizor committed Apr 10, 2017
1 parent 706ef18 commit 62adf46
Showing 1 changed file with 22 additions and 34 deletions.
56 changes: 22 additions & 34 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -412,25 +412,19 @@ export function compiler(markdown, {overrides = {}} = {}) {
const key = index || '0';

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

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

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

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

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

const inputProps = {
...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 62adf46

Please sign in to comment.