Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix raw attribute sources with multiple nodes #82

Merged
merged 4 commits into from
Oct 18, 2024

Conversation

alecgeatches
Copy link
Contributor

Description

See #81 for a description of the problem. In short, if a block with a raw source like core/html has multiple top-level nodes, the Block Data API returns only the HTML of the first node.

Block HTML:

<!-- wp:html -->
<h1>First node</h1><h2>Second node</h2>
<!-- /wp:html -->

Incorrect output:

{
    "name": "core/html",
    "attributes": {
        "content": "<h1>First node</h1>"
    }
}

The source_block_raw function responsible for gathering this HTML has been changed to use the parent wrapper block's inner HTML. This will collect all node HTML as well as preserving inner whitespace in the HTML content.

Steps to Test

  1. Check out PR.
  2. Run wp-env start and composer install.
  3. Run composer run test
  4. See successful tests.

@alecgeatches alecgeatches self-assigned this Oct 18, 2024
@alecgeatches alecgeatches requested a review from a team as a code owner October 18, 2024 17:05
@alecgeatches
Copy link
Contributor Author

Merging! Test failures are from block bindings differences in latest WordPress, unrelated to the changes here.

@alecgeatches alecgeatches merged commit 7070759 into trunk Oct 18, 2024
2 of 4 checks passed
@alecgeatches alecgeatches deleted the fix/raw-source-multiple-nodes branch October 18, 2024 18:07
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.

1 participant