-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add isRawAttribute to entity config (#34388)
* Add rawBlockMarkupFields * Add unit tests for getRawEntityRecord * Rename rawBlockMarkupFields to rawAttributes * Use POST_RAW_ATTRIBUTES instead of an inline list * Rename rawBlockMarkupFields to isRawAttribute * Add isRawAttribute selector * Make isRawAttribute a utility function instead of a selector * Remove isRawAttribute from saveEntityRecord – the logic is deceivingly similar, but is about including specific attributes regardless of their "raw-ness" * Add rawAttributes to mobile postTypeEntities * Lint * Lint * Lint
- Loading branch information
Showing
7 changed files
with
123 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/** | ||
* Checks whether the attribute is a "raw" attribute or not. | ||
* | ||
* @param {Object} entity Entity data. | ||
* @param {string} attribute Attribute name. | ||
* | ||
* @return {boolean} Is the attribute raw | ||
*/ | ||
export default function isRawAttribute( entity, attribute ) { | ||
return ( entity.rawAttributes || [] ).includes( attribute ); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/** | ||
* Internal dependencies | ||
*/ | ||
import { isRawAttribute } from '../'; | ||
|
||
describe( 'isRawAttribute', () => { | ||
it( 'should correctly assess that the attribute is not raw', () => { | ||
const entity = { | ||
kind: 'someKind', | ||
name: 'someName', | ||
}; | ||
expect( isRawAttribute( entity, 'title' ) ).toBe( false ); | ||
} ); | ||
it( 'should correctly assess that the attribute is raw', () => { | ||
const entity = { | ||
kind: 'someKind', | ||
name: 'someName', | ||
rawAttributes: [ 'title' ], | ||
}; | ||
expect( isRawAttribute( entity, 'title' ) ).toBe( true ); | ||
} ); | ||
} ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters