[wp-trac] [WordPress Trac] #62357: HTML API: Allow creating fragment parser from a context node

WordPress Trac noreply at wordpress.org
Thu Nov 21 13:28:17 UTC 2024


#62357: HTML API: Allow creating fragment parser from a context node
---------------------------------------------+-------------------------
 Reporter:  jonsurrell                       |       Owner:  jonsurrell
     Type:  feature request                  |      Status:  closed
 Priority:  normal                           |   Milestone:  6.8
Component:  HTML API                         |     Version:
 Severity:  normal                           |  Resolution:  fixed
 Keywords:  has-patch has-unit-tests commit  |     Focuses:
---------------------------------------------+-------------------------
Changes (by Bernhard Reiter):

 * status:  assigned => closed
 * resolution:   => fixed


Comment:

 In [changeset:"59444" 59444]:
 {{{
 #!CommitTicketReference repository="" revision="59444"
 HTML API: Add method to create fragment at node.

 HTML Fragment parsing always happens with a context node, which may impact
 how a fragment of HTML is parsed. HTML Fragment Processors can be
 instantiated with a `BODY` context node via
 `WP_HTML_Processor::create_fragment( $html )`.

 This changeset adds a static method called
 `create_fragment_at_current_node( string $html_fragment )`. It can only be
 called when the processor is paused at a `#tag`, with some additional
 constraints:

 - The opening and closing tags must appear in the HTML input (no virtual
 tokens).
 - No "self-contained" elements are allowed ( `IFRAME`, `SCRIPT`, `TITLE`,
 etc.).

 If successful, the method will return a `WP_HTML_Processor` instance whose
 context is inherited from the node that the method was called from.

 Props jonsurrell, bernhard-reiter, gziolo.
 Fixes #62357.
 }}}

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


More information about the wp-trac mailing list