diff --git a/packages/editor/src/utils/terms.js b/packages/editor/src/utils/terms.js index 2d34879548a56..e3154a6480a0f 100644 --- a/packages/editor/src/utils/terms.js +++ b/packages/editor/src/utils/terms.js @@ -14,14 +14,16 @@ export function buildTermsTree( flatTerms ) { const flatTermsWithParentAndChildren = flatTerms.map( ( term ) => { return { children: [], - parent: null, + parent: undefined, ...term, }; } ); // All terms should have a `parent` because we're about to index them by it. if ( - flatTermsWithParentAndChildren.some( ( { parent } ) => parent === null ) + flatTermsWithParentAndChildren.some( + ( { parent } ) => parent === undefined + ) ) { return flatTermsWithParentAndChildren; } diff --git a/packages/editor/src/utils/test/terms.js b/packages/editor/src/utils/test/terms.js index 68a1a7f10fb19..fa7d1622370c7 100644 --- a/packages/editor/src/utils/test/terms.js +++ b/packages/editor/src/utils/test/terms.js @@ -4,14 +4,14 @@ import { buildTermsTree } from '../terms'; describe( 'buildTermsTree()', () => { - it( 'Should return same array as input with null parent and empty children added if parent is never specified.', () => { + it( 'Should return same array as input with undefined parent and empty children added if parent is never specified.', () => { const input = Object.freeze( [ { id: 2232, dummy: true }, { id: 2245, dummy: true }, ] ); const output = Object.freeze( [ - { id: 2232, parent: null, children: [], dummy: true }, - { id: 2245, parent: null, children: [], dummy: true }, + { id: 2232, parent: undefined, children: [], dummy: true }, + { id: 2245, parent: undefined, children: [], dummy: true }, ] ); const termsTreem = buildTermsTree( input ); expect( termsTreem ).toEqual( output );