[wp-trac] [WordPress Trac] #64531: assertEqualHTML may ignore leading whitespace text

WordPress Trac noreply at wordpress.org
Tue Jan 20 21:05:35 UTC 2026


#64531: assertEqualHTML may ignore leading whitespace text
--------------------------------------+---------------------
 Reporter:  jonsurrell                |       Owner:  (none)
     Type:  defect (bug)              |      Status:  new
 Priority:  normal                    |   Milestone:
Component:  Build/Test Tools          |     Version:  6.9
 Severity:  normal                    |  Resolution:
 Keywords:  has-patch has-unit-tests  |     Focuses:
--------------------------------------+---------------------

Comment (by jonsurrell):

 Replying to [comment:10 dmsnell]:
 > Should produce the following tree in both cases.
 >
 > {{{
 > <p>
 >   " x"
 > }}}

 Both produce this tree, they're both wrong in a way that makes them agree:

 {{{
 <p>
   "x"
 }}}

 > I disagree that they're identical … This is because of whitespace
 normalization. If we wanted the newline we’d need a character reference
 instead of the actual newline character.

 I disagree that they're identical. Different whitespace is not treated
 identically nor is whitespace removed anywhere else in text node. The
 following two tags are not and have never been considered matches by
 `assertEqualHTML()`:

 {{{#!xml
 <p>
 x
 </p>
 <p> x </p>
 }}}

 The text in the tree representation is `x\n` in the first example and `x `
 in the second. The leading whitespace is trimmed (which I believe is a
 bug).

 ---

 Unfortunately, the history of how this came to be is not open source. The
 actual intent of the whitespace trimming is unclear, but it does not
 normalize. It simply removes some whitespace. The change that introduced
 the white space trimming was related to whitespace inside style
 attributes.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/64531#comment:11>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list