Skip to content
This repository has been archived by the owner on Jul 28, 2023. It is now read-only.

Support definition of public frontend attributes and only serialize those #15

Merged
merged 2 commits into from
May 17, 2022

Conversation

michalczaplinski
Copy link
Collaborator

Fixing #13

@@ -1,13 +1,16 @@
import { InnerBlocks, useBlockProps } from "@wordpress/block-editor";
import { registerBlockType as gutenbergRegisterBlockType } from "@wordpress/blocks";
import { getFrontendAttributes } from "./utils";
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I've put the getFrontendAttributes in a separate file for no reason other than that it's easier to mock in tests this way.

jest.mock("@wordpress/blocks", () => {
return {
__esModule: true,
getBlockType: () => ({
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We mock this function which is being called inside of the getFrontendAttributes() to give us a our fake attributes.

@michalczaplinski michalczaplinski marked this pull request as ready for review May 17, 2022 00:13
Copy link
Collaborator

@cbravobernal cbravobernal left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Member

@luisherranz luisherranz left a comment

Choose a reason for hiding this comment

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

It even has tests 😱

@luisherranz luisherranz merged commit e0c10a5 into main May 17, 2022
@luisherranz luisherranz changed the title Filter out frontend attributes without the frontend: true property Support definition of public frontend attributes and only serialize those Jun 30, 2022
@luisherranz luisherranz deleted the try/public-frontend-attributes branch September 6, 2022 10:38
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants