[wp-trac] [WordPress Trac] #60287: HTML API: P end tag does not generate P element

WordPress Trac noreply at wordpress.org
Thu Jan 18 17:25:42 UTC 2024


#60287: HTML API: P end tag does not generate P element
--------------------------+-----------------------------
 Reporter:  jonsurrell    |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  HTML API      |    Version:
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 According to the [https://html.spec.whatwg.org/multipage/parsing.html
 #parsing-main-inbody:~:text=An%20end%20tag-,whose,-tag%20name%20is%20%22p
 HTML Standard], a P end tag with no open P elements should generate an
 empty P element:

 > An end tag whose tag name is "p"
 > If the stack of open elements does not have a p element in button scope,
 then this > is a parse error; insert an HTML element for a "p" start tag
 token with no attributes.
 >
 > Close a p element.


 ----


 Behavior

 Expected:

 {{{#!php
 <?php
 $p = WP_HTML_Processor::create_fragment( '</p>' );
 assert( $p->next_tag() );
 assert( 'P' === $p->get_tag() );
 assert( ! $p->is_tag_closer() );
 }}}

 Actual:

 {{{#!php
 <?php
 $p = WP_HTML_Processor::create_fragment( '</p>' );

 // The following line errors, no tags are found.
 assert( $p->next_tag() );
 assert( 'P' === $p->get_tag() );
 assert( ! $p->is_tag_closer() );
 }}}

 ----

 [https://github.com/WordPress/wordpress-
 develop/blob/e707e37f23dcb6723ba3cea22d45f8f35ef95deb/src/wp-includes
 /html-api/class-wp-html-processor.php#L865-L874 The relevant code block is
 here] where we seem to follow the specification, but no P element is
 actually added.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/60287>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list