Skip to content

Commit

Permalink
Update getTermsInfo() to workaround parsing issue for translatable st…
Browse files Browse the repository at this point in the history
…rings (#33341)
  • Loading branch information
ocean90 authored and youknowriad committed Jul 13, 2021
1 parent a042157 commit 9d54d06
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions packages/block-library/src/query/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,8 @@ import { store as coreStore } from '@wordpress/core-data';
* @param {WPTerm[]} terms The terms to extract of helper object.
* @return {QueryTermsInfo} The object with the terms information.
*/
export const getTermsInfo = ( terms ) => ( {
terms,
...terms?.reduce(
export const getTermsInfo = ( terms ) => {
const mapping = terms?.reduce(
( accumulator, term ) => {
const { mapById, mapByName, names } = accumulator;
mapById[ term.id ] = term;
Expand All @@ -50,8 +49,13 @@ export const getTermsInfo = ( terms ) => ( {
return accumulator;
},
{ mapById: {}, mapByName: {}, names: [] }
),
} );
);

return {
terms,
...mapping,
};
};

/**
* Returns a helper object that contains:
Expand Down

0 comments on commit 9d54d06

Please sign in to comment.