Skip to content

Commit

Permalink
Revert to spread approach for better readability.
Browse files Browse the repository at this point in the history
  • Loading branch information
ZebulanStanphill committed Mar 25, 2020
1 parent 0f71e4b commit ef5ee3d
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 59 deletions.
20 changes: 6 additions & 14 deletions packages/block-editor/src/hooks/align.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,21 +89,13 @@ export function addAttribute( settings ) {
return settings;
}
if ( hasBlockSupport( settings, 'align' ) ) {
const alignAttribute = {
type: 'string',
};

// Gracefully handle if settings.attributes is undefined.
if (
typeof settings.attributes === 'object' &&
settings.attributes !== null
) {
settings.attributes.align = alignAttribute;
} else {
settings.attributes = {
align: alignAttribute,
};
}
settings.attributes = {
...settings.attributes,
align: {
type: 'string',
},
};
}

return settings;
Expand Down
26 changes: 9 additions & 17 deletions packages/block-editor/src/hooks/anchor.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,24 +38,16 @@ export function addAttribute( settings ) {
return settings;
}
if ( hasBlockSupport( settings, 'anchor' ) ) {
const anchorAttribute = {
type: 'string',
source: 'attribute',
attribute: 'id',
selector: '*',
};

// Gracefully handle if settings.attributes is undefined.
if (
typeof settings.attributes === 'object' &&
settings.attributes !== null
) {
settings.attributes.anchor = anchorAttribute;
} else {
settings.attributes = {
anchor: anchorAttribute,
};
}
settings.attributes = {
...settings.attributes,
anchor: {
type: 'string',
source: 'attribute',
attribute: 'id',
selector: '*',
},
};
}

return settings;
Expand Down
20 changes: 6 additions & 14 deletions packages/block-editor/src/hooks/custom-class-name.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,13 @@ import { InspectorAdvancedControls } from '../components';
*/
export function addAttribute( settings ) {
if ( hasBlockSupport( settings, 'customClassName', true ) ) {
const classNameAttribute = {
type: 'string',
};

// Gracefully handle if settings.attributes is undefined.
if (
typeof settings.attributes === 'object' &&
settings.attributes !== null
) {
settings.attributes.className = classNameAttribute;
} else {
settings.attributes = {
className: classNameAttribute,
};
}
settings.attributes = {
...settings.attributes,
className: {
type: 'string',
},
};
}

return settings;
Expand Down
20 changes: 6 additions & 14 deletions packages/block-editor/src/hooks/custom-class-name.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,13 @@ import {
*/
export function addAttribute( settings ) {
if ( hasBlockSupport( settings, 'customClassName', true ) ) {
const classNameAttribute = {
type: 'string',
};

// Gracefully handle if settings.attributes is undefined.
if (
typeof settings.attributes === 'object' &&
settings.attributes !== null
) {
settings.attributes.className = classNameAttribute;
} else {
settings.attributes = {
className: classNameAttribute,
};
}
settings.attributes = {
...settings.attributes,
className: {
type: 'string',
},
};
}

return settings;
Expand Down

0 comments on commit ef5ee3d

Please sign in to comment.