[wp-trac] [WordPress Trac] #62584: Support more contexts in ::create_fragment method
WordPress Trac
noreply at wordpress.org
Thu Nov 28 08:04:16 UTC 2024
#62584: Support more contexts in ::create_fragment method
--------------------------------------+-------------------------
Reporter: jonsurrell | Owner: jonsurrell
Type: feature request | Status: reopened
Priority: normal | Milestone: 6.8
Component: HTML API | Version: 6.5
Severity: normal | Resolution:
Keywords: has-patch has-unit-tests | Focuses:
--------------------------------------+-------------------------
Changes (by jonsurrell):
* status: closed => reopened
* resolution: fixed =>
Comment:
Reopening to reconsider the interface and behavior of fragments in the
HTML API. I spoke at length with @dmsnell and we decided to make the new
methods (from this ticket and #62357) for creating non-body fragments
private and consider some changes to the implementations that diverge from
the HTML standard on fragment parsing.
A good example is the following:
{{{#!php
<?php
WP_HTML_Processor::create_fragment( '<p>If this P is considered to be
under the context node, that cannot be represented in HTML.', '<p>' );
}}}
As in implemented, this produces the following tree ("under" the context
node of `<p>`):
{{{
└─P
├─#text If this P is considered to be under the context node, that's
├─EM
│ └─#text broken
└─#text HTML.
}}}
Through the lens of the HTML API, `P > P` is not something that can
//ever// be represented as HTML and may not make sense to show as a
context. The DOM APIs (where fragment parsing comes from) do support this
behavior because the DOM supports many arbitrary ways of nesting elements
that are unrepresentable in HTML.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/62584#comment:7>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list