Skip to content

Interactivity API: Apply the same directive name restrictions as the client#8048

Closed
sirreal wants to merge 3 commits intoWordPress:trunkfrom
sirreal:iapi/restrict-server-side-directive-names
Closed

Interactivity API: Apply the same directive name restrictions as the client#8048
sirreal wants to merge 3 commits intoWordPress:trunkfrom
sirreal:iapi/restrict-server-side-directive-names

Conversation

@sirreal
Copy link
Copy Markdown
Member

@sirreal sirreal commented Dec 27, 2024

Prevent the server from rendering directives that the client will ignore.

The server renders:

<div data-wp-class--bottom-[-24rem]="context.true">
<!-- as -->
<div class="bottom-[-24rem]" data-wp-class--bottom-[-24rem]="context.true">

The client does not support that behavior. It was never intended to be supported.

See WordPress/gutenberg#65803.

Trac ticket: https://core.trac.wordpress.org/ticket/62426

Todo:

  • Add tests
  • Add note to source in client to keep regexes in sync.

This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

@github-actions
Copy link
Copy Markdown

Test using WordPress Playground

The changes in this pull request can previewed and tested using a WordPress Playground instance.

WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Some things to be aware of

  • The Plugin and Theme Directories cannot be accessed within Playground.
  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Dec 27, 2024

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props jonsurrell, joemcgill.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@sirreal sirreal force-pushed the iapi/restrict-server-side-directive-names branch from a4da689 to d567914 Compare March 10, 2025 10:38
@joemcgill joemcgill self-requested a review March 20, 2025 21:35
Copy link
Copy Markdown
Member

@joemcgill joemcgill left a comment

Choose a reason for hiding this comment

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

This looks good to me.

if ( ! preg_match(
/*
* This must align with the client-side regex used by the interactivity API.
* @see https://github.com/WordPress/gutenberg/blob/ca616014255efbb61f34c10917d52a2d86c1c660/packages/interactivity/src/vdom.ts#L20-L32
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is really helpful, but can probably be improved since this URL is pinned to a specific hash. Not a blocker for commit though.

@github-actions
Copy link
Copy Markdown

A commit was made that fixes the Trac ticket referenced in the description of this pull request.

SVN changeset: 60070
GitHub commit: 804ca75

This PR will be closed, but please confirm the accuracy of this and reopen if there is more work to be done.

@github-actions github-actions bot closed this Mar 24, 2025
@sirreal sirreal deleted the iapi/restrict-server-side-directive-names branch March 24, 2025 16:07
@sirreal
Copy link
Copy Markdown
Member Author

sirreal commented Mar 24, 2025

Thanks for reviewing and landing this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants