Skip to content

Commit

Permalink
Lodash: Refactor away from _.stubTrue and _.stubFalse (#41625)
Browse files Browse the repository at this point in the history
  • Loading branch information
tyxla committed Jun 10, 2022
1 parent dbe195a commit 1b85a57
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* External dependencies
*/
import { omit, stubFalse, castArray } from 'lodash';
import { omit, castArray } from 'lodash';

/**
* Internal dependencies
Expand All @@ -11,6 +11,15 @@ import { validateBlock } from '../validation';
import { getBlockAttributes } from './get-block-attributes';
import { applyBuiltInValidationFixes } from './apply-built-in-validation-fixes';

/**
* Function that takes no arguments and always returns false.
*
* @return {boolean} Always returns false.
*/
function stubFalse() {
return false;
}

/**
* Given a block object, returns a new copy of the block with any applicable
* deprecated migrations applied, or the original block if it was both valid
Expand Down
4 changes: 2 additions & 2 deletions packages/blocks/src/api/validation/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* External dependencies
*/
import { Tokenizer } from 'simple-html-tokenizer';
import { identity, xor, fromPairs, isEqual, includes, stubTrue } from 'lodash';
import { identity, xor, fromPairs, isEqual, includes } from 'lodash';

/**
* WordPress dependencies
Expand Down Expand Up @@ -418,7 +418,7 @@ export const isEqualAttributesOfName = {
// For each boolean attribute, mere presence of attribute in both is enough
// to assume equivalence.
...fromPairs(
BOOLEAN_ATTRIBUTES.map( ( attribute ) => [ attribute, stubTrue ] )
BOOLEAN_ATTRIBUTES.map( ( attribute ) => [ attribute, () => true ] )
),
};

Expand Down

0 comments on commit 1b85a57

Please sign in to comment.