[wp-trac] [WordPress Trac] #61348: HTML API: Report real and virtual nodes in the HTML Processor.

WordPress Trac noreply at wordpress.org
Mon Jun 3 19:46:15 UTC 2024


#61348: HTML API: Report real and virtual nodes in the HTML Processor.
--------------------------------------+----------------------
 Reporter:  dmsnell                   |       Owner:  dmsnell
     Type:  enhancement               |      Status:  closed
 Priority:  normal                    |   Milestone:  6.6
Component:  HTML API                  |     Version:  trunk
 Severity:  normal                    |  Resolution:  fixed
 Keywords:  has-patch has-unit-tests  |     Focuses:
--------------------------------------+----------------------
Changes (by dmsnell):

 * owner:  (none) => dmsnell
 * status:  new => closed
 * resolution:   => fixed


Comment:

 In [changeset:"58304" 58304]:
 {{{
 #!CommitTicketReference repository="" revision="58304"
 HTML API: Report real and virtual nodes in the HTML Processor.

 HTML is a kind of short-hand for a DOM structure. This means that there
 are
 many cases in HTML where an element's opening tag or closing tag is
 missing (or
 both). This is because many of the parsing rules imply creating elements
 in the
 DOM which may not exist in the text of the HTML.

 The HTML Processor, being the higher-level counterpart to the Tag
 Processor, is
 already aware of these nodes, but since it's inception has not paused on
 them
 when scanning through a document. Instead, these are visible when pausing
 on a
 child of such an element, but otherwise not seen.

 In this patch the HTML Processor starts exposing those implicitly-created
 nodes,
 including opening tags, and closing tags, that aren't foudn in the text
 content
 of the HTML input document.

 Previously, the sequence of matched tokens when scanning with
 `WP_HTML_Processor::next_token()` would depend on how the HTML document
 was written,
 but with this patch, all semantically equal HTML documents will parse and
 scan in
 the same exact manner, presenting an idealized or "perfect" view of the
 document
 the same way as would occur when traversing a DOM in a browser.

 Developed in https://github.com/WordPress/wordpress-develop/pull/6348
 Discussed in https://core.trac.wordpress.org/ticket/61348

 Props audrasjb, dmsnell, gziolo, jonsurrell.
 Fixes #61348.
 }}}

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


More information about the wp-trac mailing list