Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ function getUniqueFontSizesBySlug( settings ) {
const fontSizes = settings?.typography?.fontSizes;
const mergedFontSizes = fontSizes ? mergeOrigins( fontSizes ) : [];
const uniqueSizes = [];
for ( const currentSize of mergedFontSizes ) {
for ( const currentSize of mergedFontSizes.reverse() ) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wouldn't use .reverse() like this. It mutates the array in-place. Having read through mergeOrigins(), it looks like it returns a new array, so it wouldn't have side-effects here, but it would be better to attach the .reverse() to mergeOrigins( fontSizes ).reverse() so the relationship between them is more clear.

Alternatively, if you don't want to mutate the original array, [].toReversed() has good browser support these days at the cost of more memory usage.

if ( ! uniqueSizes.some( ( { slug } ) => slug === currentSize.slug ) ) {
uniqueSizes.push( currentSize );
}
Expand Down