Fix test broken by assertEqualHTML whitespace change in WP 7.0 (core #64531)#1
Merged
juanmaguitar merged 1 commit intomainfrom Feb 23, 2026
Merged
Conversation
WordPress core ticket #64531 (fixed in 6.9.1, included in 7.0) corrected build_visual_html_tree() to stop trimming leading whitespace from text nodes. Whitespace-only text nodes between elements are now preserved and compared. The test_card_block_renders_with_background_color test had a multi-line $expected string that started with a newline before <div> and had newlines and tabs between </div...> and <p>. These became text nodes in the parsed tree that don't exist in the actual render output, causing the assertion to fail on WP 7.0. Fix: remove the leading newline before <div> and close the gap between the opening tag and <p> so no whitespace text nodes are introduced. Attributes can still span multiple lines for readability — whitespace inside a tag is not a text node. Also bump .wp-env.json to wordpress-7.0-beta1 to reflect the WP version this fix targets. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
sirreal
reviewed
Feb 23, 2026
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Fixes
test_card_block_renders_with_background_colorwhich started failing on WordPress 7.0.Why
WordPress core ticket #64531 corrected a bug in
build_visual_html_tree()(the function poweringassertEqualHTML). The function was incorrectly trimming leading whitespace from text nodes, including whitespace-only text nodes between elements. The fix shipped in WP 6.9.1 and is included in WP 7.0.Before the fix, this
$expectedstring passed silently:Even though the actual output had no whitespace text nodes between elements, the leading newline and the tabs between
<div>and<p>were being stripped from the tree, so the comparison appeared equal.After the fix, those whitespace-only text nodes are preserved and compared — correctly causing the assertion to fail when the actual output has no such nodes.
The fix
<div>in$expected.>of the opening tag and<p>, and between</p>and</div>.Updated the docblock to document this behaviour as a learning point for readers of these examples.
Also bumps
.wp-env.jsontowordpress-7.0-beta1to match the version under test.Key rule going forward
🤖 Generated with Claude Code